Repository: ember-cli/ember-cli
Pull request #7516 (2017-12-22 11:56:31)

Fix `ember new --yarn` not using yarn
Resolves https://github.com/ember-cli/ember-cli/issues/7511

/cc @PieterJanVdb @gossi @lennyburdette


Patch:
diff --git a/lib/tasks/addon-install.js b/lib/tasks/addon-install.js
index 0e85ef857..88716119c 100644
--- a/lib/tasks/addon-install.js
+++ b/lib/tasks/addon-install.js
@@ -25,7 +25,6 @@ class AddonInstallTask extends Task {
       ui: this.ui,
       analytics: this.analytics,
       project: this.project,
-      useYarn: commandOptions.yarn,
     });
 
     let blueprintInstall = new this.BlueprintTask({
@@ -42,6 +41,7 @@ class AddonInstallTask extends Task {
       'save': commandOptions.save,
       'save-dev': !commandOptions.save,
       'save-exact': commandOptions.saveExact,
+      useYarn: commandOptions.yarn,
     }).then(() => this.project.reloadAddons())
       .then(() => this.installBlueprint(blueprintInstall, packageNames, blueprintOptions))
       .finally(() => ui.stopProgress())
diff --git a/lib/tasks/npm-task.js b/lib/tasks/npm-task.js
index 7089d535f..09eea1bd7 100644
--- a/lib/tasks/npm-task.js
+++ b/lib/tasks/npm-task.js
@@ -136,6 +136,8 @@ class NpmTask extends Task {
   }
 
   run(options) {
+    this.useYarn = options.useYarn;
+
     return this.findPackageManager().then(() => {
       let ui = this.ui;
       let startMessage = this.formatStartMessage(options.packages);


Test patch:
diff --git a/tests/unit/commands/install-test.js b/tests/unit/commands/install-test.js
index 52154b92b..2d62cf8ba 100644
--- a/tests/unit/commands/install-test.js
+++ b/tests/unit/commands/install-test.js
@@ -106,6 +106,7 @@ describe('install command', function() {
           'save': false,
           'save-dev': true,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
       });
     });
@@ -125,6 +126,7 @@ describe('install command', function() {
           'save': false,
           'save-dev': true,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
       });
     });
@@ -138,6 +140,7 @@ describe('install command', function() {
           'save': true,
           'save-dev': false,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
       });
     });
@@ -157,6 +160,7 @@ describe('install command', function() {
           'save': true,
           'save-dev': false,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
       });
     });
@@ -200,6 +204,7 @@ describe('install command', function() {
           'save': false,
           'save-dev': true,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
 
         let generateRun = tasks.GenerateFromBlueprint.prototype.run;
@@ -217,6 +222,7 @@ describe('install command', function() {
           'save': false,
           'save-dev': true,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
 
         let generateRun = tasks.GenerateFromBlueprint.prototype.run;
@@ -233,6 +239,7 @@ describe('install command', function() {
           'save': false,
           'save-dev': true,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
 
         let generateRun = tasks.GenerateFromBlueprint.prototype.run;
@@ -250,6 +257,7 @@ describe('install command', function() {
           'save': false,
           'save-dev': true,
           'save-exact': false,
+          useYarn: undefined,
         }), { times: 1 });
 
         let generateRun = tasks.GenerateFromBlueprint.prototype.run;