diff --git a/commands/index.js b/commands/index.js index e425c29..d2bde02 100644 --- a/commands/index.js +++ b/commands/index.js @@ -30,16 +30,16 @@ const SHARED = { }, _ensureConfigFile() { + let configPath = getConfigPath(this.project); + try { - return this.project.resolveSync('./config/optional-features.json'); + return this.project.resolveSync(configPath); } catch(err) { if (err.code !== 'MODULE_NOT_FOUND') { throw err; } } - let configPath = getConfigPath(this.project); - mkdirp.sync(path.join(this.project.root, path.dirname(configPath))); fs.writeFileSync(configPath, '{}', { encoding: 'UTF-8' }); diff --git a/tests/commands-test.js b/tests/commands-test.js index 13b1249..9bad7ff 100644 --- a/tests/commands-test.js +++ b/tests/commands-test.js @@ -199,6 +199,45 @@ QUnit.module('commands', hooks => { ` }, 'it should have rewritten the config file with the appropiate flags'); })); + + QUnit.test('it rewrites the config file with a custom config path', co.wrap(function *(assert) { + project.write({ + 'package.json': strip` + { + "name": "dummy", + "description": "", + "version": "0.0.0", + "devDependencies": { + "@ember/optional-features": "*", + "ember-cli": "*", + "ember-source": "*" + }, + "ember-addon": { + "configPath": "foo/bar" + } + } + ` + }); + + project.write({ + 'optional-features.json': strip(` + { + "template-only-glimmer-components": true + } + `) + }, 'foo/bar'); + + yield run(testCase.command, 'application-template-wrapper', { input: 'no\n' }); + + assert.deepEqual(project.read('foo/bar'), { + 'optional-features.json': strip` + { + "application-template-wrapper": ${testCase.expected}, + "template-only-glimmer-components": true + } + ` + }, 'it should have rewritten the config file with the appropiate flags'); + })); }); });