1
0
mirror of https://github.com/go-task/task.git synced 2025-08-08 22:36:57 +02:00

Dry run small code style changes

This commit is contained in:
Andrey Nering
2018-08-05 11:28:02 -03:00
parent 27fc4c4ca8
commit a5f31a4280
5 changed files with 15 additions and 11 deletions

View File

@@ -55,7 +55,7 @@ func main() {
watch bool
verbose bool
silent bool
dryRun bool
dry bool
dir string
)
@@ -67,7 +67,7 @@ func main() {
pflag.BoolVarP(&watch, "watch", "w", false, "enables watch of the given task")
pflag.BoolVarP(&verbose, "verbose", "v", false, "enables verbose mode")
pflag.BoolVarP(&silent, "silent", "s", false, "disables echoing")
pflag.BoolVar(&dryRun, "dry", false, "compiles and prints tasks in the order that they would be run, without executing them")
pflag.BoolVar(&dry, "dry", false, "compiles and prints tasks in the order that they would be run, without executing them")
pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution")
pflag.Parse()
@@ -93,7 +93,7 @@ func main() {
Verbose: verbose,
Silent: silent,
Dir: dir,
DryRun: dryRun,
Dry: dry,
Context: getSignalContext(),

View File

@@ -35,7 +35,7 @@ type Executor struct {
Watch bool
Verbose bool
Silent bool
DryRun bool
Dry bool
Context context.Context
@@ -212,7 +212,7 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi
e.Logger.Errf(cmd.Cmd)
}
if e.DryRun {
if e.Dry {
return nil
}

View File

@@ -433,8 +433,8 @@ func TestExpand(t *testing.T) {
assert.Equal(t, home, strings.TrimSpace(buff.String()))
}
func TestDryRun(t *testing.T) {
const dir = "testdata/dryrun"
func TestDry(t *testing.T) {
const dir = "testdata/dry"
file := filepath.Join(dir, "file.txt")
_ = os.Remove(file)
@@ -445,11 +445,12 @@ func TestDryRun(t *testing.T) {
Dir: dir,
Stdout: &buff,
Stderr: &buff,
DryRun: true,
Dry: true,
}
assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(taskfile.Call{Task: "build"}))
assert.Equal(t, "touch file.txt", strings.TrimSpace(buff.String()))
if _, err := os.Stat(file); err == nil {
t.Errorf("File should not exist %s", file)
}

6
testdata/dry/Taskfile.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: '2'
tasks:
build:
cmds:
- touch file.txt

View File

@@ -1,3 +0,0 @@
build:
cmds:
- touch file.txt