Skip to content

Commit

Permalink
Throw error if logging disabled and jsutils not available
Browse files Browse the repository at this point in the history
  • Loading branch information
gitKrystan committed May 17, 2023
1 parent 1681df3 commit 38feacc
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/this-fallback-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,32 @@ class NoopPlugin implements ASTPlugin {
visitor = {};
}

function buildThisFallbackPlugin(
options: EmberThisFallbackOptions
): ASTPluginBuilder<Env> {
function buildThisFallbackPlugin({
enableLogging,
}: EmberThisFallbackOptions): ASTPluginBuilder<Env> {
return (env) => {
const name = 'ember-this-fallback';
const logger = options.enableLogging
const logger = enableLogging
? createLogger(`${name}-plugin`, env.moduleName)
: noopLogger();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (env.meta.jsutils) {
return new ThisFallbackPlugin(name, env, logger);
} else {
logger.error([
const errorMessage = [
'The this-fallback-plugin relies on the JSUtils from babel-plugin-ember-template-compilation, but none were found.',
'To resolve this issue, please ensure you are running the latest version of ember-cli-htmlbars.',
]);
return new NoopPlugin(name);
];
if (enableLogging) {
logger.error([
'The this-fallback-plugin relies on the JSUtils from babel-plugin-ember-template-compilation, but none were found.',
'To resolve this issue, please ensure you are running the latest version of ember-cli-htmlbars.',
]);
return new NoopPlugin(name);
} else {
throw new Error(errorMessage.join(' '));
}
}
};
}
Expand Down

0 comments on commit 38feacc

Please sign in to comment.