Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
prompt before overwriting pipeline.js (#336)
Browse files Browse the repository at this point in the history
if pipeline.js already exists, prompt user for y/n on whether to continue; also, only write example pipeline with all arguments

fixes #320
  • Loading branch information
jipperinbham authored Mar 24, 2017
1 parent d009340 commit 5881fbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## v0.3.1 [UNRELEASED]
## v0.3.1 [2017-03-24]

### Features
- added `js` alias for `goja` transform function [#335](https://github.com/compose/transporter/pull/335)
- `init` command will now prompt user when `pipeline.js` file already exists [#336](https://github.com/compose/transporter/pull/336)

### Bugfixes
- fixed mongodb, rabbitmq, and rethinkdb adaptors from not trying to read from a file when provided in the `ca_certs` field [#334](https://github.com/compose/transporter/pull/334)
Expand Down
14 changes: 11 additions & 3 deletions cmd/transporter/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"strings"

"github.com/compose/transporter/adaptor"
)
Expand All @@ -18,6 +19,15 @@ func runInit(args []string) error {
if len(args) != 2 {
return fmt.Errorf("wrong number of arguments provided, expected 2, got %d", len(args))
}
if _, err := os.Stat("pipeline.js"); err == nil {
fmt.Print("pipeline.js exists, overwrite? (y/n) ")
var overwrite string
fmt.Scanln(&overwrite)
if strings.ToLower(overwrite) != "y" {
fmt.Println("not overwriting pipeline.js, exiting...")
return nil
}
}
fmt.Println("Writing pipeline.js...")
appFileHandle, err := os.Create(defaultPipelineFile)
if err != nil {
Expand All @@ -34,9 +44,7 @@ func runInit(args []string) error {
return fmt.Errorf("adaptor '%s' did not provide a sample config", name)
}
}
appFileHandle.WriteString(`t.Source(source).Save(sink)`)
appFileHandle.WriteString(`// t.Source("source", source).Save("sink", sink)`)
appFileHandle.WriteString(`// t.Source("source", source, "/.*/").Save("sink", sink, "/.*/")`)
appFileHandle.WriteString(`t.Source("source", source, "/.*/").Save("sink", sink, "/.*/")`)
appFileHandle.WriteString("\n")
return nil
}

0 comments on commit 5881fbc

Please sign in to comment.