Skip to content

Commit

Permalink
Merge pull request #88 from giusdp/main
Browse files Browse the repository at this point in the history
Update goja_nodes and zipf
  • Loading branch information
francescotimperi authored Sep 8, 2023
2 parents dd86003 + fb1a352 commit 1398a1e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
22 changes: 17 additions & 5 deletions tools/zipf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <folder> [-o <zipfile>] [-x <command>]
Expand All @@ -60,9 +62,6 @@ Options:`)
return err
}

log.Println("zipf", flag.Args())
log.Println("zipf nargs", flag.NArg())

if *help {
flag.Usage()
return nil
Expand All @@ -81,20 +80,33 @@ 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)
if err != nil {
return err
}
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) {
Expand Down

0 comments on commit 1398a1e

Please sign in to comment.