Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow chained commands and setting env vars in commands #107

Merged
merged 4 commits into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
matrix:
fast_finish: true
include:
- node_js: "4.2"
- node_js: "6"
env: NPM_SCRIPT=client-test
- node_js: "6"
env: NPM_SCRIPT=jscs
Expand Down
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.
25 changes: 17 additions & 8 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 @@ -58,12 +61,12 @@ ember try default --skip-cleanup
# ember try test1 --config-path='test/fixtures/dummy-ember-try-config.js' --skip-cleanup true

# custom command with all styles of options
ember try default help --json
ember try default help --json=true
ember try default help --json true
ember try default help --silent
ember try default help --silent=true
ember try default help --silent true

# custom command mixed with ember try's own option
ember try default help --json --skip-cleanup
ember try default help --silent --skip-cleanup

# try:one <scenario>
ember try:one default
Expand All @@ -83,13 +86,19 @@ ember try:one test1 --config-path='test/fixtures/dummy-ember-try-config.js'
ember try:one test1 --config-path='test/fixtures/dummy-ember-try-config.js' --skip-cleanup true

# custom command with all styles of options
ember try:one default --- ember help --json
ember try:one default --- ember help --json=true
ember try:one default --- ember help --json true
ember try:one default --- ember help --silent
ember try:one default --- ember help --silent=true
ember try:one default --- ember help --silent true

# custom command mixed with ember try's own option
ember try:one default --skip-cleanup --- ember help --json
ember try:one default --skip-cleanup --- ember help --silent


# 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 with ', sh, [shFlag, cmdArgs], opts);
var didTimeout = false;
if (opts.timeout) {
setTimeout(function() {
Expand Down