Skip to content

Commit a5738dc

Browse files
committed
Change exec cmd from spawnSync to execSync
1 parent c254d48 commit a5738dc

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var argv = require('minimist')(process.argv.slice(2), {
1212
v: 'version'
1313
}
1414
});
15-
var exec = require('child_process').spawnSync;
15+
var exec = require('child_process').execSync;
1616
var cwd = (function getCwd(dir) {
1717
return dir ? dir : process.cwd();
1818
})(argv._[0]);

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ module.exports = function (p, exec, log, cwd, tasks, options) {
3737
var values = answer.task;
3838
values = Array.isArray(values) ? values : [values];
3939
values.forEach(function (answer) {
40-
exec('npm', [
40+
exec([
41+
'npm',
4142
'run',
4243
answer
43-
], {
44+
].join(' '), {
4445
cwd: cwd,
4546
stdio: [
4647
p.stdin,

test/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ test.cb(function shouldDisplayHelp(t) {
7777
});
7878

7979
test.cb(function shouldSelectDefaultTask(t) {
80-
var testExec = function (name, args) {
81-
t.is(name + ' ' + args.join(' '), 'npm run start');
80+
var testExec = function (name) {
81+
t.is(name, 'npm run start');
8282
t.end();
8383
};
8484
var prompt = ntl(t.context.p, testExec, log, cwd, tasks, options);
8585
prompt.rl.emit('line');
8686
});
8787

8888
test.cb(function shouldSelectTask(t) {
89-
var testExec = function (name, args) {
90-
t.is(name + ' ' + args.join(' '), 'npm run build');
89+
var testExec = function (name) {
90+
t.is(name, 'npm run build');
9191
t.end();
9292
};
9393
var prompt = ntl(t.context.p, testExec, log, cwd, tasks, options);
@@ -97,8 +97,8 @@ test.cb(function shouldSelectTask(t) {
9797
});
9898

9999
test.cb(function shouldSelectPrefixedTasksWithAllFlag(t) {
100-
var testExec = function (name, args) {
101-
t.is(name + ' ' + args.join(' '), 'npm run pretest');
100+
var testExec = function (name) {
101+
t.is(name, 'npm run pretest');
102102
t.end();
103103
};
104104
var prompt = ntl(t.context.p, testExec, log, cwd, tasks, {all: true});
@@ -107,8 +107,8 @@ test.cb(function shouldSelectPrefixedTasksWithAllFlag(t) {
107107
});
108108

109109
test.cb(function shouldDisplayScriptContentsWithInfoFlag(t) {
110-
var testExec = function (name, args) {
111-
t.is(name + ' ' + args.join(' '), 'npm run test');
110+
var testExec = function (name) {
111+
t.is(name, 'npm run test');
112112
t.end();
113113
};
114114
var prompt = ntl(t.context.p, testExec, log, cwd, tasks, {info: true});
@@ -118,8 +118,8 @@ test.cb(function shouldDisplayScriptContentsWithInfoFlag(t) {
118118

119119
test.cb(function shouldSelectMultipleTasksUsingFlag(t) {
120120
var count = 0;
121-
var testExec = function (name, args) {
122-
t.ok(args[1] in {start: 1, debug: 1});
121+
var testExec = function (name) {
122+
t.ok(name.split(' ')[2] in {start: 1, debug: 1});
123123
if (++count > 1) {
124124
t.end();
125125
}

0 commit comments

Comments
 (0)