Skip to content

Commit

Permalink
Allow chained commands and setting env vars in commands
Browse files Browse the repository at this point in the history
- Add note to readme about needing to npm link ember-try
  • Loading branch information
kategengler committed Oct 26, 2016
1 parent c9c6482 commit 99675a8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 9 additions & 0 deletions all-commands.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
set -ex

npm link
npm link ember-try

# try:each
ember try:each

Expand Down Expand Up @@ -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'
5 changes: 5 additions & 0 deletions fail-if-no-foo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

if [[ $FOO == "" ]]; then
exit 1
fi
14 changes: 12 additions & 2 deletions lib/utils/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 99675a8

Please sign in to comment.