Skip to content

Commit f4ff8d5

Browse files
committed
Add an extraCliArgs option to the emberNew helper
This makes it possible to pass any extra arguments to ember-cli, which makes it possible to test more blueprint scenarios.
1 parent e86b189 commit f4ff8d5

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Create a new Ember.js app or addon in the current working directory.
174174

175175
- `{Object} [options]` optional parameters
176176
- `{String} [options.target='app']` the type of project to create (`app`, `addon` or `in-repo-addon`)
177+
- `{string[]} [options.extraCliArgs=[]]` any extra arguments you want to pass to ember-cli
177178

178179
**Returns:** `{Promise}`
179180

lib/ember-new.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const rethrowFromErrorLog = require('./rethrow-from-error-log');
1212
*
1313
* @param {Object} [options] optional parameters
1414
* @param {String} [options.target='app'] the type of project to create (`app`, `addon` or `in-repo-addon`)
15+
* @param {string[]} [options.extraCliArgs] any extra arguments you want to pass to ember-cli
1516
* @returns {Promise}
1617
*/
1718
module.exports = function(options) {
@@ -22,12 +23,13 @@ module.exports = function(options) {
2223

2324
let projectName = isAddon ? 'my-addon' : 'my-app';
2425
let command = isAddon ? 'addon' : 'new';
26+
let extraCliArgs = Array.isArray(options.extraCliArgs) ? options.extraCliArgs : [];
2527

2628
let cliOptions = {
2729
disableDependencyChecker: true
2830
};
2931

30-
return ember([command, projectName, '--skip-npm', '--skip-bower'], cliOptions)
32+
return ember([command, projectName, '--skip-npm', '--skip-bower', ...extraCliArgs], cliOptions)
3133
.then(generateInRepoAddon(target))
3234
.then(linkAddon)
3335
.catch(rethrowFromErrorLog);

tests/acceptance/helpers-test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const expect = chai.expect;
1414
const dir = chai.dir;
1515
const file = chai.file;
1616

17-
describe('Acceptance: helpers', function() {
17+
describe('Acceptance: helpers', function () {
1818
setupTestHooks(this);
1919

2020
describe('emberNew', () => {
@@ -33,6 +33,14 @@ describe('Acceptance: helpers', function() {
3333
expect(fs.existsSync(addonPath)).to.equal(true);
3434
});
3535
});
36+
37+
it('emberNew - extraCliArgs', () => {
38+
return emberNew({ extraCliArgs: ['--typescript', '--no-welcome']})
39+
.then(() => {
40+
const appPath = path.resolve(process.cwd(), 'app');
41+
expect(fs.existsSync(appPath)).to.equal(true);
42+
});
43+
});
3644
});
3745

3846
describe('emberGenerateDestroy', () => {

0 commit comments

Comments
 (0)