Abdulhaq Emhemmed f6ca2d76f3 fix(@angular/cli): Use appropriate packageManager for linking
When creating a new project using the --link-cli option, the
linking command was hard-coded to use npm link @angular/cli.
This commit replicates the behaviour of npm-install where the
package manager is obtained from the global config and is then
used for linking.

Close #5524
2017-03-29 10:58:37 +01:00

27 lines
711 B
TypeScript

const Task = require('../ember-cli/lib/models/task');
import * as chalk from 'chalk';
import {exec} from 'child_process';
export default Task.extend({
run: function() {
const ui = this.ui;
let packageManager = this.packageManager;
if (packageManager === 'default') {
packageManager = 'npm';
}
return new Promise(function(resolve, reject) {
exec(`${packageManager} link @angular/cli`, (err) => {
if (err) {
ui.writeLine(chalk.red(`Couldn't do '${packageManager} link @angular/cli'.`));
reject();
} else {
ui.writeLine(chalk.green('Successfully linked to @angular/cli.'));
resolve();
}
});
});
}
});