add mkdir
This commit is contained in:
parent
2f705435c1
commit
c6bf664b50
7
file.go
7
file.go
@ -21,6 +21,13 @@ func init() {
|
|||||||
args := gojs.MakeArgs(&argsIn, vm).Check(1)
|
args := gojs.MakeArgs(&argsIn, vm).Check(1)
|
||||||
return vm.ToValue(u.FileExists(args.Path(0)))
|
return vm.ToValue(u.FileExists(args.Path(0)))
|
||||||
},
|
},
|
||||||
|
"mkdir": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
|
||||||
|
args := gojs.MakeArgs(&argsIn, vm).Check(1)
|
||||||
|
if err := os.MkdirAll(args.Path(0), 0755); err != nil {
|
||||||
|
panic(vm.NewGoError(err))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
"read": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
|
"read": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
|
||||||
args := gojs.MakeArgs(&argsIn, vm).Check(1)
|
args := gojs.MakeArgs(&argsIn, vm).Check(1)
|
||||||
if r, err := u.ReadFile(args.Path(0)); err == nil {
|
if r, err := u.ReadFile(args.Path(0)); err == nil {
|
||||||
|
2
file.ts
2
file.ts
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
exists,
|
exists,
|
||||||
|
mkdir,
|
||||||
read,
|
read,
|
||||||
readBytes,
|
readBytes,
|
||||||
write,
|
write,
|
||||||
@ -15,6 +16,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function exists(filename: string): boolean { return false }
|
function exists(filename: string): boolean { return false }
|
||||||
|
function mkdir(filename: string): void { }
|
||||||
function read(filename: string): string { return '' }
|
function read(filename: string): string { return '' }
|
||||||
function readBytes(filename: string): any { return null }
|
function readBytes(filename: string): any { return null }
|
||||||
function write(filename: string, data: any): void { }
|
function write(filename: string, data: any): void { }
|
||||||
|
12
go.mod
12
go.mod
@ -3,20 +3,20 @@ module apigo.cc/gojs/file
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
apigo.cc/gojs v0.0.4
|
apigo.cc/gojs v0.0.8
|
||||||
github.com/ssgo/u v1.7.9
|
github.com/ssgo/u v1.7.13
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
||||||
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
|
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
|
||||||
github.com/ssgo/config v1.7.7 // indirect
|
github.com/ssgo/config v1.7.9 // indirect
|
||||||
github.com/ssgo/log v1.7.7 // indirect
|
github.com/ssgo/log v1.7.7 // indirect
|
||||||
github.com/ssgo/standard v1.7.7 // indirect
|
github.com/ssgo/standard v1.7.7 // indirect
|
||||||
github.com/ssgo/tool v0.4.27 // indirect
|
github.com/ssgo/tool v0.4.27 // indirect
|
||||||
golang.org/x/sys v0.26.0 // indirect
|
golang.org/x/sys v0.28.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/text v0.21.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user