Skip to content

Commit 0caa382

Browse files
committed
Update documentation and fix command executions
1 parent e88da3a commit 0caa382

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
A simple package to execute shell commands on linux, darwin and windows.
1010

11+
## Installation
12+
13+
`$ go get -u github.com/SimonBaeumer/[email protected]`
14+
1115
## Usage
1216

1317
```go
@@ -25,7 +29,7 @@ fmt.Println(cmd.Stderr())
2529
### Stream output to stderr and stdout
2630

2731
```go
28-
cmd := NewCommand("echo hello", WithStandardStreams)
32+
cmd := NewCommand("echo hello", cmd.WithStandardStreams)
2933
cmd.Execute()
3034
```
3135

@@ -54,8 +58,4 @@ make test
5458

5559
### ToDo
5660

57-
- Reports
58-
- Coverage reports
59-
- Go report
60-
- Codeclimate
6161
- os.Stdout and os.Stderr output access after execution

command_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
func createBaseCommand(c *Command) *exec.Cmd {
9-
cmd := exec.Command("/bin/sh", "-Command", c.Command)
9+
cmd := exec.Command("/bin/sh", "-c", c.Command)
1010
return cmd
1111
}
1212

command_darwin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func TestCommand_ExecuteStderr(t *testing.T) {
1111
err := cmd.Execute()
1212

1313
assert.Nil(t, err)
14-
assert.Equal(t, "hello", cmd.Stderr())
14+
assert.Equal(t, "hello\n", cmd.Stderr())
1515
}
1616

1717
func TestCommand_WithTimeout(t *testing.T) {

command_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ func TestCommand_Execute(t *testing.T) {
2222

2323
assert.Nil(t, err)
2424
assert.True(t, cmd.Executed())
25-
assert.Equal(t, cmd.Stdout(), "hello\n")
25+
if runtime.GOOS == "windows" {
26+
assert.Equal(t, cmd.Stdout(), "hello\r\n")
27+
} else {
28+
assert.Equal(t, cmd.Stdout(), "hello\n")
29+
}
2630
}
2731

2832
func TestCommand_ExitCode(t *testing.T) {

command_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
func createBaseCommand(c *Command) *exec.Cmd {
9-
cmd := exec.Command(`Command:\windows\system32\cmd.exe`, "/C", c.Command)
9+
cmd := exec.Command(`C:\windows\system32\cmd.exe`, "/C", c.Command)
1010
return cmd
1111
}
1212

0 commit comments

Comments
 (0)