Skip to content

Commit

Permalink
refactor(generic): use cross-spawn-promise instead of spawn-rx
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Sep 25, 2017
1 parent eafbb70 commit 5a9848c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
"resolve-package": "^1.0.1",
"s3": "^4.4.0",
"semver": "^5.3.0",
"spawn-rx": "^2.0.7",
"sudo-prompt": "^7.0.0",
"tabtab": "^2.2.1",
"username": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/installers/darwin/dmg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from 'child_process';
import spawnPromise from 'cross-spawn-promise';
import fs from 'fs-extra';
import path from 'path';

Expand All @@ -24,7 +24,7 @@ export default async (filePath, installSpinner) => {

await moveApp(appPath, targetApplicationPath, installSpinner, true);

spawn('open', ['-R', targetApplicationPath], { detached: true });
await spawnPromise('open', ['-R', targetApplicationPath], { detached: true });
} finally {
await unmountImage(targetMount);
}
Expand Down
13 changes: 4 additions & 9 deletions src/installers/darwin/zip.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { spawn } from 'child_process';
import spawnPromise from 'cross-spawn-promise';
import fs from 'fs-extra';
import path from 'path';
import moveApp from '../../util/move-app';

export default async (filePath, installSpinner) => {
await new Promise((resolve) => {
const child = spawn('unzip', ['-q', '-o', path.basename(filePath)], {
cwd: path.dirname(filePath),
});
child.stdout.on('data', () => {});
child.stderr.on('data', () => {});
child.on('exit', () => resolve());
await spawnPromise('unzip', ['-q', '-o', path.basename(filePath)], {
cwd: path.dirname(filePath),
});

const appPath = (await fs.readdir(path.dirname(filePath))).filter(file => file.endsWith('.app'))
Expand All @@ -21,5 +16,5 @@ export default async (filePath, installSpinner) => {

await moveApp(appPath, targetApplicationPath, installSpinner);

spawn('open', ['-R', targetApplicationPath], { detached: true });
await spawnPromise('open', ['-R', targetApplicationPath], { detached: true });
};
4 changes: 2 additions & 2 deletions src/makers/win32/appx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import parseAuthor from 'parse-author';
import windowsStore from 'electron-windows-store';
import { isValidPublisherName, makeCert } from 'electron-windows-store/lib/sign';

import { findActualExecutable } from 'spawn-rx';
import resolveCommand from 'cross-spawn/lib/util/resolveCommand';
import { ensureDirectory } from '../../util/ensure-output';
import configFn from '../../util/config-fn';

Expand All @@ -22,7 +22,7 @@ const windowsSdkPath = process.arch === 'x64' ?
function findSdkTool(exe) {
let sdkTool = path.join(windowsSdkPath, exe);
if (!fs.existsSync(sdkTool)) {
sdkTool = findActualExecutable(exe, []).cmd;
sdkTool = resolveCommand(exe, true);
}

if (!fs.existsSync(sdkTool)) {
Expand Down
4 changes: 2 additions & 2 deletions src/util/hdiutil.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawnPromise } from 'spawn-rx';
import spawnPromise from 'cross-spawn-promise';
import debug from 'debug';

const d = debug('electron-forge:hdiutil');
Expand Down Expand Up @@ -26,7 +26,7 @@ export const getMountedImages = async () => {

export const mountImage = async (filePath) => {
d('mounting image:', filePath);
const output = await spawnPromise('hdiutil', ['attach', '-noautoopen', '-nobrowse', '-noverify', filePath]);
const output = await spawnPromise('hdiutil', ['attach', '-noautoopen', '-nobrowse', '-noverify', filePath]).toString();
const mountPath = /\/Volumes\/(.+)\n/g.exec(output)[1];
d('mounted at:', mountPath);

Expand Down
4 changes: 2 additions & 2 deletions src/util/yarn-or-npm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import crossSpawn from 'cross-spawn-promise';
import spawnPromise from 'cross-spawn-promise';
import logSymbols from 'log-symbols';
import yarnOrNpm from 'yarn-or-npm';

Expand All @@ -18,6 +18,6 @@ const safeYarnOrNpm = () => {

export default safeYarnOrNpm;

export const yarnOrNpmSpawn = (...args) => crossSpawn(safeYarnOrNpm(), ...args);
export const yarnOrNpmSpawn = (...args) => spawnPromise(safeYarnOrNpm(), ...args);

export const hasYarn = () => safeYarnOrNpm() === 'yarn';

0 comments on commit 5a9848c

Please sign in to comment.