Skip to content

Commit

Permalink
run provided command
Browse files Browse the repository at this point in the history
  • Loading branch information
dekokun committed Aug 8, 2020
1 parent 136dc4c commit 2bbdefd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion json2env.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func Run(ctx context.Context, argv []string, outStream, errStream io.Writer, inS
if err := fs.Parse(argv); err != nil {
return err
}
command := fs.Args()
if *ver {
return printVersion(outStream)
}
Expand All @@ -35,7 +36,6 @@ func Run(ctx context.Context, argv []string, outStream, errStream io.Writer, inS
if err != nil {
return errors.Wrapf(err, "failed to decode input %+s", inStream)
}
command := []string{"env"}
newEnv := makeNewEnv(env, envJSON)
if err := runCommand(command, newEnv); err != nil {
return errors.Wrapf(err, "failed to run command %+s", command)
Expand Down
4 changes: 2 additions & 2 deletions json2env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (

func TestNormal(t *testing.T) {
stdin := bytes.NewBufferString("{}")
err := Run(context.Background(), []string{}, &bytes.Buffer{}, &bytes.Buffer{}, stdin, []string{})
err := Run(context.Background(), []string{"ls"}, &bytes.Buffer{}, &bytes.Buffer{}, stdin, []string{})
if err != nil {
t.Fatalf("failed test %#v", err)
}
}

func TestErrorIfNotJson(t *testing.T) {
stdin := bytes.NewBufferString("{deadbeaf")
err := Run(context.Background(), []string{}, &bytes.Buffer{}, &bytes.Buffer{}, stdin, []string{})
err := Run(context.Background(), []string{"ls"}, &bytes.Buffer{}, &bytes.Buffer{}, stdin, []string{})
if err == nil {
t.Fatalf("error not occurred, failed test %#v", err)
}
Expand Down

0 comments on commit 2bbdefd

Please sign in to comment.