Skip to content

Commit f6ca2d7

Browse files
abdulhaq-efilipesilva
authored andcommitted
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 angular#5524
1 parent 798a4c7 commit f6ca2d7

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

packages/@angular/cli/tasks/init.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ export default Task.extend({
3333
});
3434
}
3535

36+
const packageManager = CliConfig.fromGlobal().get('packageManager');
37+
3638
let npmInstall: any;
3739
if (!commandOptions.skipInstall) {
38-
const packageManager = CliConfig.fromGlobal().get('packageManager');
3940
npmInstall = new NpmInstall({
4041
ui: this.ui,
4142
project: this.project,
@@ -47,7 +48,8 @@ export default Task.extend({
4748
if (commandOptions.linkCli) {
4849
linkCli = new LinkCli({
4950
ui: this.ui,
50-
project: this.project
51+
project: this.project,
52+
packageManager
5153
});
5254
}
5355

@@ -105,4 +107,3 @@ export default Task.extend({
105107
});
106108
}
107109
});
108-

packages/@angular/cli/tasks/link-cli.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ export default Task.extend({
66
run: function() {
77
const ui = this.ui;
88

9+
let packageManager = this.packageManager;
10+
if (packageManager === 'default') {
11+
packageManager = 'npm';
12+
}
13+
914
return new Promise(function(resolve, reject) {
10-
exec('npm link @angular/cli', (err) => {
15+
exec(`${packageManager} link @angular/cli`, (err) => {
1116
if (err) {
12-
ui.writeLine(chalk.red('Couldn\'t do \'npm link @angular/cli\'.'));
17+
ui.writeLine(chalk.red(`Couldn't do '${packageManager} link @angular/cli'.`));
1318
reject();
1419
} else {
1520
ui.writeLine(chalk.green('Successfully linked to @angular/cli.'));

0 commit comments

Comments
 (0)