Skip to content
Closed
Prev Previous commit
Next Next commit
Check status of process
  • Loading branch information
Timer committed Nov 19, 2017
commit b52f311b9a0095d0bd64e874bdd53ce44cd60b27
33 changes: 25 additions & 8 deletions packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,37 @@ function adjustPackages(cwd, packages, append, dev) {
if (!Array.isArray(packages)) {
packages = [packages];
}
let status;
if (fs.existsSync(paths.yarnLockFile)) {
spawnSync('yarnpkg', [append ? 'add' : 'remove', ...packages], {
stdio: 'inherit',
cwd,
});
({ status } = spawnSync(
'yarnpkg',
[append ? 'add' : 'remove', ...packages],
{
stdio: 'pipe',
cwd,
}
));
} else {
spawnSync(
({ status } = spawnSync(
'npm',
[append ? 'install' : 'uninstall', dev ? '-D' : '-S', ...packages],
[
append ? 'install' : 'uninstall',
dev ? '-D' : '-S',
'--loglevel',
'error',
...packages,
],
{
stdio: 'inherit',
stdio: 'pipe',
cwd,
}
);
));
}

if (status !== 0) {
console.error(chalk.red('Failed to update the dependencies.'));

process.exit(status);
}
}

Expand Down