Skip to content

Commit 38b5e5b

Browse files
committed
Fix command ignoring existing config in an addon
Fixes #74
1 parent 060cbb3 commit 38b5e5b

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

commands/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ const SHARED = {
3030
},
3131

3232
_ensureConfigFile() {
33+
let configPath = getConfigPath(this.project);
34+
3335
try {
34-
return this.project.resolveSync('./config/optional-features.json');
36+
return this.project.resolveSync(configPath);
3537
} catch(err) {
3638
if (err.code !== 'MODULE_NOT_FOUND') {
3739
throw err;
3840
}
3941
}
4042

41-
let configPath = getConfigPath(this.project);
42-
4343
mkdirp.sync(path.join(this.project.root, path.dirname(configPath)));
4444

4545
fs.writeFileSync(configPath, '{}', { encoding: 'UTF-8' });

tests/commands-test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,45 @@ QUnit.module('commands', hooks => {
199199
`
200200
}, 'it should have rewritten the config file with the appropiate flags');
201201
}));
202+
203+
QUnit.test('it rewrites the config file with a custom config path', co.wrap(function *(assert) {
204+
project.write({
205+
'package.json': strip`
206+
{
207+
"name": "dummy",
208+
"description": "",
209+
"version": "0.0.0",
210+
"devDependencies": {
211+
"@ember/optional-features": "*",
212+
"ember-cli": "*",
213+
"ember-source": "*"
214+
},
215+
"ember-addon": {
216+
"configPath": "foo/bar"
217+
}
218+
}
219+
`
220+
});
221+
222+
project.write({
223+
'optional-features.json': strip(`
224+
{
225+
"template-only-glimmer-components": true
226+
}
227+
`)
228+
}, 'foo/bar');
229+
230+
yield run(testCase.command, 'application-template-wrapper', { input: 'no\n' });
231+
232+
assert.deepEqual(project.read('foo/bar'), {
233+
'optional-features.json': strip`
234+
{
235+
"application-template-wrapper": ${testCase.expected},
236+
"template-only-glimmer-components": true
237+
}
238+
`
239+
}, 'it should have rewritten the config file with the appropiate flags');
240+
}));
202241
});
203242
});
204243

0 commit comments

Comments
 (0)