Skip to content

Commit

Permalink
Merge pull request #15 from paralin/gopherjs-compat
Browse files Browse the repository at this point in the history
Support build / run under wasm / gopherjs
  • Loading branch information
mcuadros committed Apr 21, 2021
2 parents 3d7f61f + 36058ce commit 8d1f328
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions osfs/os.go
@@ -1,3 +1,5 @@
// +build !js

// Package osfs provides a billy filesystem for the OS.
package osfs // import "github.com/go-git/go-billy/v5/osfs"

Expand Down
23 changes: 23 additions & 0 deletions osfs/os_js.go
@@ -0,0 +1,23 @@
package osfs

import (
"github.com/go-git/go-billy/v5"
"github.com/go-git/go-billy/v5/helper/chroot"
"github.com/go-git/go-billy/v5/memfs"
)

// globalMemFs is the global memory fs
var globalMemFs = memfs.New()

const (
defaultDirectoryMode = 0755
defaultCreateMode = 0666
)

// OS is a filesystem shim for js.
type OS struct{}

// New returns a new OS filesystem.
func New(baseDir string) billy.Filesystem {
return chroot.New(globalMemFs, baseDir)
}
2 changes: 1 addition & 1 deletion osfs/os_posix.go
@@ -1,4 +1,4 @@
// +build !plan9,!windows
// +build !plan9,!windows,!js

package osfs

Expand Down

0 comments on commit 8d1f328

Please sign in to comment.