Skip to content

Commit 50b2001

Browse files
Kelly Seldenkellyselden
authored andcommitted
convert to spawn
1 parent 5c2433d commit 50b2001

7 files changed

Lines changed: 26 additions & 22 deletions

File tree

src/download-package.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const path = require('path');
44
const { createTmpDir } = require('./tmp');
55
const npa = require('npm-package-arg');
6-
const run = require('./run');
6+
const { spawn } = require('./run');
77

88
async function downloadPackage(name, url, range) {
99
if (!range) {
@@ -17,11 +17,11 @@ async function downloadPackage(name, url, range) {
1717
}
1818

1919
let newTmpDir = await createTmpDir();
20-
let output = await run(`npm install ${url}`, { cwd: newTmpDir });
20+
let { stdout } = await spawn('npm', ['install', url], { cwd: newTmpDir });
2121
// if (!name) {
22-
// name = output.match(/^\+ (.*)@\d\.\d\.\d.*$/m)[1];
22+
// name = stdout.match(/^\+ (.*)@\d\.\d\.\d.*$/m)[1];
2323
// }
24-
let arg = output.match(/^\+ (.*)$/m)[1];
24+
let arg = stdout.match(/^\+ (.*)$/m)[1];
2525
let parsed = npa(arg);
2626
name = parsed.name;
2727
let version = parsed.rawSpec;

src/get-start-and-end-commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const path = require('path');
44
const fs = require('fs-extra');
55
const execa = require('execa');
6-
const run = require('./run');
6+
const { spawn } = require('./run');
77
const utils = require('./utils');
88
const isDefaultBlueprint = require('./is-default-blueprint');
99
const emberInstallAddon = require('./ember-install-addon');
@@ -260,7 +260,7 @@ module.exports.installAddonBlueprint = async function installAddonBlueprint({
260260
blueprint
261261
}) {
262262
// `not found: ember` without this
263-
await run('npm install', { cwd: projectRoot });
263+
await spawn('npm', ['install'], { cwd: projectRoot });
264264

265265
let { ps } = await emberInstallAddon({
266266
cwd: projectRoot,

src/run.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
const execa = require('execa');
44
const debug = require('./debug');
55

6-
module.exports = async function run() {
7-
debug(...arguments);
6+
function spawn(bin, args = [], options) {
7+
debug(bin, ...args.map(arg => `"${arg}"`), options);
88

9-
let { stdout } = await execa.command(...arguments);
9+
let ps = execa(...arguments);
1010

11-
if (stdout) {
12-
debug(stdout);
13-
}
11+
ps.stdout.on('data', data => {
12+
debug(data.toString());
13+
});
1414

15-
return stdout;
15+
return ps;
16+
}
17+
18+
module.exports = {
19+
spawn
1620
};

src/stage-blueprint-file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

33
const path = require('path');
4-
const run = require('./run');
4+
const { spawn } = require('./run');
55

66
async function stageBlueprintFile({
77
cwd,
88
emberCliUpdateJsonPath
99
}) {
1010
let relative = path.relative(cwd, emberCliUpdateJsonPath);
1111

12-
await run(`git add ${relative}`, {
12+
await spawn('git', ['add', relative], {
1313
cwd
1414
});
1515
}

test/acceptance/ember-cli-update-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const {
1616
assertCodemodRan
1717
} = require('../helpers/assertions');
1818
const { initBlueprint } = require('../helpers/blueprint');
19-
const run = require('../../src/run');
19+
const { spawn } = require('../../src/run');
2020
const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file');
2121
const overwriteBlueprintFiles = require('../../src/overwrite-blueprint-files');
2222
const { defaultTo } = require('../../src/constants');
@@ -408,7 +408,7 @@ describe(function() {
408408
relativeDir: location
409409
});
410410

411-
await run('npm install', { cwd: tmpPath });
411+
await spawn('npm', ['install'], { cwd: tmpPath });
412412
}
413413
});
414414

test/integration/install-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
fixtureCompare: _fixtureCompare
1111
} = require('git-fixtures');
1212
const install = require('../../src/install');
13-
const run = require('../../src/run');
13+
const { spawn } = require('../../src/run');
1414
const {
1515
assertNoStaged
1616
} = require('../helpers/assertions');
@@ -85,7 +85,7 @@ describe(install, function() {
8585
relativeDir: location
8686
});
8787

88-
await run('npm install', { cwd: tmpPath });
88+
await spawn('npm', ['install'], { cwd: tmpPath });
8989
},
9090
async afterMerge() {
9191
await fs.remove(path.join(tmpPath, 'package-lock.json'));

test/integration/overwrite-blueprint-files-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {
66
buildTmp
77
} = require('git-fixtures');
88
const overwriteBlueprintFiles = require('../../src/overwrite-blueprint-files');
9-
const run = require('../../src/run');
9+
const { spawn } = require('../../src/run');
1010
const { initBlueprint } = require('../helpers/blueprint');
1111
const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file');
1212
const sinon = require('sinon');
@@ -31,9 +31,9 @@ describe(overwriteBlueprintFiles, function() {
3131
relativeDir: location
3232
});
3333

34-
await run('npm install', { cwd: tmpPath });
34+
await spawn('npm', ['install'], { cwd: tmpPath });
3535

36-
await run(`npm install ${blueprintPath}`, { cwd: tmpPath });
36+
await spawn('npm', ['install', blueprintPath], { cwd: tmpPath });
3737

3838
let ps = ember(['g', packageName], { cwd: tmpPath, stdin: 'pipe' });
3939

0 commit comments

Comments
 (0)