Skip to content
Permalink
Browse files

fix(init): run package manager commands via cross-spawn

Allows dependencies with carets to be escaped properly on Windows.
  • Loading branch information
malept committed Sep 21, 2017
1 parent 50d3537 commit cbee55e2986c0613a19edc9b1c7c4e10c7bece17
Showing with 24 additions and 2 deletions.
  1. +1 −0 package.json
  2. +2 −2 src/util/yarn-or-npm.js
  3. +21 −0 test/slow/install-dependencies_spec_slow.js
@@ -104,6 +104,7 @@
"bluebird": "^3.4.6",
"colors": "^1.1.2",
"commander": "^2.9.0",
"cross-spawn-promise": "^0.10.1",
"debug": "^3.0.0",
"electron-forge-template-angular2": "^1.0.3",
"electron-forge-template-react": "^1.0.2",
@@ -1,4 +1,4 @@
import { spawnPromise } from 'spawn-rx';
import crossSpawn from 'cross-spawn-promise';
import logSymbols from 'log-symbols';
import yarnOrNpm from 'yarn-or-npm';

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

export default safeYarnOrNpm;

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

export const hasYarn = () => safeYarnOrNpm() === 'yarn';
@@ -0,0 +1,21 @@
import { expect } from 'chai';
import fs from 'fs-extra';
import os from 'os';
import path from 'path';

import installDeps from '../../src/util/install-dependencies';

describe('install-dependencies', () => {
const installDir = path.resolve(os.tmpdir(), 'electron-forge-test-install-dependencies');

before(async () => { fs.ensureDir(installDir); });

it('should install the latest minor version when the dependency has a caret', async () => {
await installDeps(installDir, ['debug@^2.0.0']);

const packageJSON = require(path.resolve(installDir, 'node_modules', 'debug', 'package.json'));
expect(packageJSON.version).to.not.equal('2.0.0');
});

after(async () => await fs.remove(installDir));
});

0 comments on commit cbee55e

Please sign in to comment.
You can’t perform that action at this time.