Skip to content
Merged
Changes from 1 commit
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
19 changes: 10 additions & 9 deletions src/install-peerdeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ function encodePackageName(packageName) {
* @returns {Promise} - a Promise which resolves when the install process is finished
*/
const spawnCommand = (command, args) => {
const isWindows = process.platform === "win32";
let extra = "";
if (isWindows && !command.endsWith(".cmd")) {
// Spawn doesn't work without this extra stuff in Windows
// See https://github.com/nodejs/node/issues/3675
extra = ".cmd";
}

return new Promise((resolve, reject) => {
let stdout = "";
let stderr = "";
const cmdProcess = spawn(command, args, {
const cmdProcess = spawn(command + extra, args, {
cwd: process.cwd()
});
cmdProcess.stdout.on("data", chunk => {
Expand Down Expand Up @@ -229,13 +237,6 @@ function installPeerDeps(
if (!dev) {
devFlag = "";
}
const isWindows = process.platform === "win32";
let extra = "";
if (isWindows) {
// Spawn doesn't work without this extra stuff in Windows
// See https://github.com/nodejs/node/issues/3675
extra = ".cmd";
}

let args = [];
// I know I can push it, but I'll just
Expand Down Expand Up @@ -301,7 +302,7 @@ function installPeerDeps(
} else {
console.log(`Installing peerdeps for ${packageName}@${version}.`);
console.log(commandString);
spawnCommand(packageManager + extra, args)
spawnCommand(packageManager, args)
.then(() => cb(null))
.catch(err => cb(err));
}
Expand Down