From 385683109fa3d2638c790d38869d6a84ecd1621b Mon Sep 17 00:00:00 2001 From: Giuseppe De Palma Date: Fri, 8 Sep 2023 10:40:15 +0200 Subject: [PATCH 1/2] update goja deps --- go.mod | 2 +- go.sum | 8 ++++++++ tools/zipf.go | 5 ++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 16f232e..81cce94 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/nuvolaris/goja v0.0.0-20230826140625-f4c22086ede6 // indirect - github.com/nuvolaris/goja_nodejs v0.0.0-20230830173113-e0ab07ae0f02 // indirect + github.com/nuvolaris/goja_nodejs v0.0.0-20230908085513-c4634a0b1160 // indirect github.com/nuvolaris/sh/v3 v3.0.0-20230718131820-376e733299a4 // indirect github.com/nuvolaris/task/v3 v3.9.3-0.20230718131831-48d06b3099ca // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect diff --git a/go.sum b/go.sum index e5a6314..53cd15f 100644 --- a/go.sum +++ b/go.sum @@ -290,6 +290,14 @@ github.com/nuvolaris/goja_nodejs v0.0.0-20230830171817-96fda7aef746 h1:zovyJudao github.com/nuvolaris/goja_nodejs v0.0.0-20230830171817-96fda7aef746/go.mod h1:bik1pvnsEagEp/uCTjjKUHVWPyuy53ETukJZVuaSG2U= github.com/nuvolaris/goja_nodejs v0.0.0-20230830173113-e0ab07ae0f02 h1:Zy16V8qVX5ik3+D1uJT1p0oOVhumMV7cpDRozuNkquw= github.com/nuvolaris/goja_nodejs v0.0.0-20230830173113-e0ab07ae0f02/go.mod h1:bik1pvnsEagEp/uCTjjKUHVWPyuy53ETukJZVuaSG2U= +github.com/nuvolaris/goja_nodejs v0.0.0-20230907081244-1f70814cad15 h1:XYf7CKq7ZP0GMTEVXA7EkMZ3O3VzJX6TfjbGDkV5hyo= +github.com/nuvolaris/goja_nodejs v0.0.0-20230907081244-1f70814cad15/go.mod h1:bik1pvnsEagEp/uCTjjKUHVWPyuy53ETukJZVuaSG2U= +github.com/nuvolaris/goja_nodejs v0.0.0-20230908084725-4fe8389b8bc8 h1:PJnckbBlyPRDSjOFb6jBO/UEU2MYZUdCKn24awKT1ME= +github.com/nuvolaris/goja_nodejs v0.0.0-20230908084725-4fe8389b8bc8/go.mod h1:bik1pvnsEagEp/uCTjjKUHVWPyuy53ETukJZVuaSG2U= +github.com/nuvolaris/goja_nodejs v0.0.0-20230908085230-3aacac3fb29b h1:Lq88pRXoo0z14m+WkkzMztrC9yfSg7mlMjwSmvv3EOk= +github.com/nuvolaris/goja_nodejs v0.0.0-20230908085230-3aacac3fb29b/go.mod h1:bik1pvnsEagEp/uCTjjKUHVWPyuy53ETukJZVuaSG2U= +github.com/nuvolaris/goja_nodejs v0.0.0-20230908085513-c4634a0b1160 h1:/PhIMFTHKYzupL5wnmwTKlqW2nrx+8GBs9gN82YW8Yw= +github.com/nuvolaris/goja_nodejs v0.0.0-20230908085513-c4634a0b1160/go.mod h1:bik1pvnsEagEp/uCTjjKUHVWPyuy53ETukJZVuaSG2U= github.com/nuvolaris/openwhisk-cli/commands v0.0.0-20230615104118-d593f7d6576f h1:gYjKmnboe18DpSc4yIOa9Rqp4oQKIMbxzAt7NkSpEKQ= github.com/nuvolaris/openwhisk-cli/commands v0.0.0-20230615104118-d593f7d6576f/go.mod h1:Gv6ayVTiLPzMp3oA808nO5JxwXSN//vWxMu+qtG6Rf8= github.com/nuvolaris/openwhisk-cli/wski18n v0.0.0-20221227222349-fba31e174b7e h1:JEpF1YOoZKTU3U7k57Km3FytF6CaEAx0MkYIlGH5X34= diff --git a/tools/zipf.go b/tools/zipf.go index 74501a8..c4d14fd 100644 --- a/tools/zipf.go +++ b/tools/zipf.go @@ -60,9 +60,6 @@ Options:`) return err } - log.Println("zipf", flag.Args()) - log.Println("zipf nargs", flag.NArg()) - if *help { flag.Usage() return nil @@ -94,6 +91,8 @@ Options:`) if err != nil { return err } + + log.Println("saving zip file to", *out) return os.WriteFile(*out, stdout, 0644) } From fb1a3523993bb8386af6df5d6efb63112684282a Mon Sep 17 00:00:00 2001 From: Giuseppe De Palma Date: Fri, 8 Sep 2023 11:28:19 +0200 Subject: [PATCH 2/2] small zipf tool update --- tools/zipf.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/zipf.go b/tools/zipf.go index c4d14fd..7652558 100644 --- a/tools/zipf.go +++ b/tools/zipf.go @@ -44,6 +44,8 @@ You can specify the output file with the -o option to override the default name. You can pass a command with the -x option. The command is a shell command that is executed on the zipped folder and its output is saved as the output file. +N.B.: The zip file is saved in the same parent folder of the input folder. + Usage: nuv -zipf [-o ] [-x ] @@ -78,13 +80,20 @@ Options:`) } } + *out = filepath.Join(filepath.Dir(dir), *out) + buf, err := Zip(dir) if err != nil { return err } if *cmd == "" { - return os.WriteFile(*out, buf, 0644) + err = os.WriteFile(*out, buf, 0644) + if err != nil { + return err + } + log.Println(*out) + return nil } stdout, err := runCommandWithStdin(*cmd, buf) @@ -92,8 +101,12 @@ Options:`) return err } - log.Println("saving zip file to", *out) - return os.WriteFile(*out, stdout, 0644) + err = os.WriteFile(*out, stdout, 0644) + if err != nil { + return err + } + log.Println(*out) + return nil } func runCommandWithStdin(cmd string, stdin []byte) ([]byte, error) {