From 99675a88b16da1bab15de4d71f125e8026346c7d Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Wed, 26 Oct 2016 19:40:16 -0400 Subject: [PATCH] Allow chained commands and setting env vars in commands - Add note to readme about needing to npm link ember-try --- .npmignore | 1 - README.md | 5 +++++ all-commands.sh | 9 +++++++++ fail-if-no-foo.sh | 5 +++++ lib/utils/run.js | 14 ++++++++++++-- 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100755 fail-if-no-foo.sh diff --git a/.npmignore b/.npmignore index b6c10c0e..d990ff37 100644 --- a/.npmignore +++ b/.npmignore @@ -20,7 +20,6 @@ bower.json ember-cli-build.js testem.js all-commands.sh -test-win-commands.sh lint-test.js testem.json upload-coverage.sh diff --git a/README.md b/README.md index 2d9d363e..fa1315a3 100644 --- a/README.md +++ b/README.md @@ -238,3 +238,8 @@ See an example of using `ember-try` for CI [here](https://github.com/kategengler ### Special Thanks - Much credit is due to [Edward Faulkner](https://github.com/ef4) The scripts in [liquid-fire](https://github.com/ef4/liquid-fire) that test against multiple ember versions were the inspiration for this project. + + +### Developing + +- Be sure to run `npm link` and `npm link ember-try`, otherwise any `ember try` commands you run will use the version of ember-try included by ember-cli itself. diff --git a/all-commands.sh b/all-commands.sh index 4464ca77..7a67737c 100755 --- a/all-commands.sh +++ b/all-commands.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -ex +npm link +npm link ember-try + # try:each ember try:each @@ -93,3 +96,9 @@ ember try:one default --skip-cleanup --- ember help --json # try:reset ember try:reset + +FOO="5" ember try:one default --- ./fail-if-no-foo.sh + +ember try:one default --- FOO=5 ./fail-if-no-foo.sh + +ember try:one default --- 'echo 1 && echo 2' diff --git a/fail-if-no-foo.sh b/fail-if-no-foo.sh new file mode 100755 index 00000000..2437b0e7 --- /dev/null +++ b/fail-if-no-foo.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +if [[ $FOO == "" ]]; then + exit 1 +fi diff --git a/lib/utils/run.js b/lib/utils/run.js index 21acf677..9f516126 100644 --- a/lib/utils/run.js +++ b/lib/utils/run.js @@ -12,9 +12,19 @@ function run(command, args, opts) { opts.stdio = 'ignore'; } + var sh = 'sh'; + var shFlag = '-c'; + + if (process.platform === 'win32') { + sh = process.env.comspec || 'cmd'; + shFlag = '/d /s /c'; + opts.windowsVerbatimArguments = true; + } + return new RSVP.Promise(function(resolve, reject) { - var p = spawn(command, args, opts); - debug('spawned: ', command, args, opts); + var cmdArgs = command + " " + args.join(' '); + var p = spawn(sh, [shFlag, cmdArgs], opts); + debug('spawned: ', sh, [shFlag, cmdArgs], opts); var didTimeout = false; if (opts.timeout) { setTimeout(function() {