Skip to content

Commit 9956622

Browse files
committed
Add Yarn option
1 parent a73e8c8 commit 9956622

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ The following options exist:
135135
| emberDataVersion | Set the version of ember-data, as you would in your `package.json` | emberjs/data#master |
136136
| fixturesPath | The path to look for your fixture files (see below) | test/fixtures |
137137
| noFixtures | Disables the use of fixture files | false |
138+
| yarn | Use yarn instead of npm | false |
138139

139140

140141
### Fixtures

lib/utilities/pristine.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function installPristineApp(appName, options) {
8181
chdir(temp.pristinePath);
8282

8383
// Install a vanilla app and cd into it
84-
let args = generateArgsForEmberNew(hasNodeModules, hasBowerComponents);
84+
let args = generateArgsForEmberNew(hasNodeModules, hasBowerComponents, options);
8585
let promise = runNew(appName, args)
8686
.catch(handleResult)
8787
.then(() => chdir(path.join(temp.pristinePath, appName)));
@@ -91,7 +91,8 @@ function installPristineApp(appName, options) {
9191
hasNodeModules,
9292
hasBowerComponents,
9393
emberVersion: options.emberVersion || 'canary',
94-
emberDataVersion: options.emberDataVersion || 'emberjs/data#master'
94+
emberDataVersion: options.emberDataVersion || 'emberjs/data#master',
95+
yarn: options.yarn || false
9596
};
9697

9798
promise = promise
@@ -111,9 +112,14 @@ function installPristineApp(appName, options) {
111112

112113
// Generates the arguments to pass to `ember new`. Optionally skipping the
113114
// npm and/or bower installation phases.
114-
function generateArgsForEmberNew(skipNpm, skipBower) {
115+
function generateArgsForEmberNew(skipNpm, skipBower, options) {
115116
let extraOptions = [];
116117

118+
if (options.yarn) {
119+
debug('using yarn');
120+
extraOptions.push('--yarn');
121+
}
122+
117123
if (skipNpm) {
118124
debug('skipping npm');
119125
extraOptions.push('--skip-npm');
@@ -142,11 +148,19 @@ function nodeModulesSetup(options) {
142148
promise = promise
143149
.then(() => {
144150
debug('installing ember-disable-prototype-extensions');
145-
return runCommand('npm', 'install', 'ember-disable-prototype-extensions');
151+
if (options.yarn) {
152+
return runCommand('yarn', 'add', 'ember-disable-prototype-extensions');
153+
} else {
154+
return runCommand('npm', 'install', 'ember-disable-prototype-extensions');
155+
}
146156
})
147157
.then(() => {
148158
debug("installed ember-disable-prototype-extension");
149-
return runCommand('npm', 'install');
159+
if (options.yarn) {
160+
return runCommand('yarn');
161+
} else {
162+
return runCommand('npm', 'install');
163+
}
150164
})
151165
.then(() => debug('installed ember-data ' + emberDataVersion))
152166
.then(() => symlinkAddon(appName))

test/acceptance/application-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ describe('Acceptance | application', function() {
4343
promoteHtmlbars();
4444

4545
return app.create('dummy', {
46-
fixturesPath: 'tests'
46+
fixturesPath: 'tests',
47+
yarn: true
4748
});
4849
}).then(function() {
4950
process.chdir(previousCwd);
5051
}).then(function() {
5152
app.editPackageJSON(function(pkg) {
5253
pkg.devDependencies['ember-cli-fastboot'] = process.env.npm_package_devDependencies_ember_cli_fastboot;
5354
});
54-
return app.run('npm', 'install');
55+
return app.run('yarn', 'install');
5556
});
5657
});
5758

0 commit comments

Comments
 (0)