Skip to content

Commit 36058ce

Browse files
committed
osfs: add js shim
Signed-off-by: Christian Stewart <christian@paral.in>
1 parent 3d7f61f commit 36058ce

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

osfs/os.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build !js
2+
13
// Package osfs provides a billy filesystem for the OS.
24
package osfs // import "github.com/go-git/go-billy/v5/osfs"
35

osfs/os_js.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package osfs
2+
3+
import (
4+
"github.com/go-git/go-billy/v5"
5+
"github.com/go-git/go-billy/v5/helper/chroot"
6+
"github.com/go-git/go-billy/v5/memfs"
7+
)
8+
9+
// globalMemFs is the global memory fs
10+
var globalMemFs = memfs.New()
11+
12+
const (
13+
defaultDirectoryMode = 0755
14+
defaultCreateMode = 0666
15+
)
16+
17+
// OS is a filesystem shim for js.
18+
type OS struct{}
19+
20+
// New returns a new OS filesystem.
21+
func New(baseDir string) billy.Filesystem {
22+
return chroot.New(globalMemFs, baseDir)
23+
}

osfs/os_posix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !plan9,!windows
1+
// +build !plan9,!windows,!js
22

33
package osfs
44

0 commit comments

Comments
 (0)