-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/cli): wait for install to finish before exiting
- Loading branch information
1 parent
93d5717
commit aebf4c8
Showing
3 changed files
with
26 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
const Task = require('../ember-cli/lib/models/task'); | ||
import * as chalk from 'chalk'; | ||
import {exec} from 'child_process'; | ||
import {checkYarnOrCNPM} from '../utilities/check-package-manager'; | ||
import { exec } from 'child_process'; | ||
|
||
|
||
export default Task.extend({ | ||
run: function() { | ||
run: function () { | ||
const ui = this.ui; | ||
let packageManager = this.packageManager; | ||
if (packageManager === 'default') { | ||
packageManager = 'npm'; | ||
} | ||
|
||
return checkYarnOrCNPM().then(function () { | ||
ui.writeLine(chalk.green(`Installing packages for tooling via ${packageManager}.`)); | ||
let installCommand = `${packageManager} install`; | ||
if (packageManager === 'npm') { | ||
installCommand = `${packageManager} --quiet install`; | ||
} | ||
ui.writeLine(chalk.green(`Installing packages for tooling via ${packageManager}.`)); | ||
let installCommand = `${packageManager} install`; | ||
if (packageManager === 'npm') { | ||
installCommand = `${packageManager} --quiet install`; | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
exec(installCommand, | ||
(err: NodeJS.ErrnoException, _stdout: string, stderr: string) => { | ||
if (err) { | ||
ui.writeLine(stderr); | ||
const message = 'Package install failed, see above.'; | ||
ui.writeLine(chalk.red(message)); | ||
throw new Error(message); | ||
} else { | ||
ui.writeLine(chalk.green(`Installed packages for tooling via ${packageManager}.`)); | ||
} | ||
}); | ||
if (err) { | ||
ui.writeLine(stderr); | ||
const message = 'Package install failed, see above.'; | ||
ui.writeLine(chalk.red(message)); | ||
reject(message); | ||
} else { | ||
ui.writeLine(chalk.green(`Installed packages for tooling via ${packageManager}.`)); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters