From f4ff8d5f06fea2164292d2c7cae0e81004c6ce73 Mon Sep 17 00:00:00 2001 From: Sam Van Campenhout Date: Tue, 10 Dec 2024 12:03:26 +0100 Subject: [PATCH] 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. --- README.md | 1 + lib/ember-new.js | 4 +++- tests/acceptance/helpers-test.js | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c70152a..2c70d4e 100644 --- a/README.md +++ b/README.md @@ -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}` diff --git a/lib/ember-new.js b/lib/ember-new.js index d59ccf9..9d6c3cc 100644 --- a/lib/ember-new.js +++ b/lib/ember-new.js @@ -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) { @@ -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); diff --git a/tests/acceptance/helpers-test.js b/tests/acceptance/helpers-test.js index a8e49a3..d544fa5 100644 --- a/tests/acceptance/helpers-test.js +++ b/tests/acceptance/helpers-test.js @@ -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', () => { @@ -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', () => {