diff --git a/file.go b/file.go index 925ad93..27bb2d2 100644 --- a/file.go +++ b/file.go @@ -21,6 +21,13 @@ func init() { args := gojs.MakeArgs(&argsIn, vm).Check(1) 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 { args := gojs.MakeArgs(&argsIn, vm).Check(1) if r, err := u.ReadFile(args.Path(0)); err == nil { diff --git a/file.ts b/file.ts index 33acf4a..765ef3f 100644 --- a/file.ts +++ b/file.ts @@ -2,6 +2,7 @@ export default { exists, + mkdir, read, readBytes, write, @@ -15,6 +16,7 @@ export default { } function exists(filename: string): boolean { return false } +function mkdir(filename: string): void { } function read(filename: string): string { return '' } function readBytes(filename: string): any { return null } function write(filename: string, data: any): void { } diff --git a/go.mod b/go.mod index 502aa0d..e990687 100644 --- a/go.mod +++ b/go.mod @@ -3,20 +3,20 @@ module apigo.cc/gojs/file go 1.18 require ( - apigo.cc/gojs v0.0.4 - github.com/ssgo/u v1.7.9 + apigo.cc/gojs v0.0.8 + github.com/ssgo/u v1.7.13 ) require ( 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/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/standard v1.7.7 // indirect github.com/ssgo/tool v0.4.27 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect )