Skip to content

Commit 3d75c52

Browse files
Copilotkategengler
andcommitted
Change unknown feature error to warning
Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com>
1 parent 31a0473 commit 3d75c52

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const SilentError = require('silent-error');
4+
const chalk = require('chalk');
45

56
const FEATURES = require('./features');
67
const getConfigPath = require('./utils').getConfigPath;
@@ -42,8 +43,10 @@ module.exports = {
4243
let keys = Object.keys(features);
4344
keys.forEach((key) => {
4445
if (FEATURES[key] === undefined) {
45-
throw new SilentError(
46-
`Unknown feature "${key}" found in config/optional-features.json`
46+
console.warn(
47+
chalk.yellow(
48+
`Warning: Unknown feature "${key}" found in config/optional-features.json`
49+
)
4750
);
4851
} else if (features[key] !== null && typeof features[key] !== 'boolean') {
4952
throw new SilentError(

tests/optional-features-test.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,23 @@ QUnit.module('@ember/optional-features', (hooks) => {
5252
return projectRoot.dispose();
5353
});
5454

55-
QUnit.test('it throws on invalid key', (assert) => {
56-
assert.throws(() => buildAddon({ foo: true }), /Unknown feature "foo"/);
55+
QUnit.test('it warns on invalid key', (assert) => {
56+
let originalWarn = console.warn;
57+
let warningMessage = null;
58+
console.warn = (msg) => {
59+
warningMessage = msg;
60+
};
61+
try {
62+
let addon = buildAddon({ foo: true });
63+
assert.ok(
64+
warningMessage && warningMessage.includes('Unknown feature "foo"'),
65+
'Should warn about unknown feature'
66+
);
67+
// The addon should still initialize successfully
68+
assert.ok(addon.config, 'Addon should be initialized');
69+
} finally {
70+
console.warn = originalWarn;
71+
}
5772
});
5873

5974
QUnit.test('it throws on invalid value', (assert) => {

0 commit comments

Comments
 (0)