Skip to content

Commit

Permalink
Merge pull request #18419 from emberjs/fix-feature-detection
Browse files Browse the repository at this point in the history
[BUGFIX release] Fix Octane feature detection
  • Loading branch information
chancancode authored Sep 21, 2019
2 parents ac860dc + b9442f0 commit 27d1398
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ module.exports = {

if (has('octane')) {
let optionalFeatures = this.project.addons.find(a => a.name === '@ember/optional-features');
let optionalFeaturesMissing = optionalFeatures !== undefined;
let missingFeatures = [];
let optionalFeaturesMissing = optionalFeatures === undefined;
let message = [];

if (optionalFeaturesMissing) {
missingFeatures.push(
message.push(
`* the @ember/optional-features addon is missing, run \`ember install @ember/optional-features\` to install it`
);
}

if (optionalFeaturesMissing || optionalFeatures.isFeatureEnabled('jquery-integration')) {
missingFeatures.push(
message.push(
`* The jquery-integration optional feature should be disabled under Octane, run \`ember feature:disable jquery-integration\` to disable it`
);
}
Expand All @@ -89,25 +89,27 @@ module.exports = {
optionalFeaturesMissing ||
optionalFeatures.isFeatureEnabled('application-template-wrapper')
) {
missingFeatures.push(
message.push(
`* The application-template-wrapper optional feature should be disabled under Octane, run \`ember feature:disable application-template-wrapper\` to disable it`
);
}

if (
optionalFeaturesMissing ||
!optionalFeatures.isFeatureEnabled('template-only-glimmer-component')
!optionalFeatures.isFeatureEnabled('template-only-glimmer-components')
) {
missingFeatures.push(
`* The template-only-glimmer-component optional feature should be enabled under Octane, run \`ember feature:enabled template-only-glimmer-component\` to enable it`
message.push(
`* The template-only-glimmer-components optional feature should be enabled under Octane, run \`ember feature:enabled template-only-glimmer-components\` to enable it`
);
}

if (missingFeatures.length > 0) {
let intro = `You have configured your application to indicate that it is using the 'octane' edition (via \`setEdition('octane')\`), but the appropriate Octane features were not enabled:`;
if (message.length > 0) {
message.unshift(
`You have configured your application to indicate that it is using the 'octane' edition (via \`setEdition('octane')\`), but the appropriate Octane features were not enabled:\n`
);

const SilentError = require('silent-error');
throw new SilentError(`${intro}\n\n${missingFeatures.join('\n\t')}`);
throw new SilentError(message.join('\n\t'));
}
}
},
Expand Down

0 comments on commit 27d1398

Please sign in to comment.