Skip to content

Commit

Permalink
Add an extraCliArgs option to the emberNew helper
Browse files Browse the repository at this point in the history
This makes it possible to pass any extra arguments to ember-cli, which makes it possible to test more blueprint scenarios.
  • Loading branch information
Windvis committed Dec 10, 2024
1 parent e86b189 commit f4ff8d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Create a new Ember.js app or addon in the current working directory.

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

**Returns:** `{Promise}`

Expand Down
4 changes: 3 additions & 1 deletion lib/ember-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const rethrowFromErrorLog = require('./rethrow-from-error-log');
*
* @param {Object} [options] optional parameters
* @param {String} [options.target='app'] the type of project to create (`app`, `addon` or `in-repo-addon`)
* @param {string[]} [options.extraCliArgs] any extra arguments you want to pass to ember-cli
* @returns {Promise}
*/
module.exports = function(options) {
Expand All @@ -22,12 +23,13 @@ module.exports = function(options) {

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

let cliOptions = {
disableDependencyChecker: true
};

return ember([command, projectName, '--skip-npm', '--skip-bower'], cliOptions)
return ember([command, projectName, '--skip-npm', '--skip-bower', ...extraCliArgs], cliOptions)
.then(generateInRepoAddon(target))
.then(linkAddon)
.catch(rethrowFromErrorLog);
Expand Down
10 changes: 9 additions & 1 deletion tests/acceptance/helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const expect = chai.expect;
const dir = chai.dir;
const file = chai.file;

describe('Acceptance: helpers', function() {
describe('Acceptance: helpers', function () {
setupTestHooks(this);

describe('emberNew', () => {
Expand All @@ -33,6 +33,14 @@ describe('Acceptance: helpers', function() {
expect(fs.existsSync(addonPath)).to.equal(true);
});
});

it('emberNew - extraCliArgs', () => {
return emberNew({ extraCliArgs: ['--typescript', '--no-welcome']})
.then(() => {
const appPath = path.resolve(process.cwd(), 'app');
expect(fs.existsSync(appPath)).to.equal(true);
});
});
});

describe('emberGenerateDestroy', () => {
Expand Down

0 comments on commit f4ff8d5

Please sign in to comment.