Skip to content

Commit

Permalink
chore(assetDir): build warning for assetDir
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Aug 6, 2020
1 parent cec8500 commit 762160a
Showing 1 changed file with 9 additions and 6 deletions.
@@ -1,5 +1,5 @@
import * as d from '../../../declarations';
import { augmentDiagnosticWithNode, buildError, validateComponentTag } from '@utils';
import { augmentDiagnosticWithNode, buildError, validateComponentTag, isString, buildWarn } from '@utils';
import { getDeclarationParameters } from './decorator-utils';
import { convertValueToLiteral, createStaticGetter } from '../transform-utils';
import { styleToStatic } from './style-to-static';
Expand Down Expand Up @@ -39,14 +39,17 @@ export const componentDecoratorToStatic = (
styleToStatic(newMembers, componentOptions);

const assetsDirs = componentOptions.assetsDirs || [];

if (isString((componentOptions as any).assetsDir)) {
assetsDirs.push((componentOptions as any).assetsDir);
const warn = buildWarn(diagnostics);
warn.messageText = `@Component option "assetsDir" should be renamed to "assetsDirs" and the value should be an array of strings.`;
augmentDiagnosticWithNode(warn, componentDecorator);
}

if (assetsDirs.length > 0) {
newMembers.push(createStaticGetter('assetsDirs', convertValueToLiteral(assetsDirs)));
}
if (typeof (componentOptions as any).assetsDir === 'string') {
const err = buildError(diagnostics);
err.messageText = `@Component option "assetsDir" should be renamed to "assetsDirs" and the value should be an array of strings.`;
augmentDiagnosticWithNode(err, componentDecorator);
}
};

const validateComponent = (
Expand Down

0 comments on commit 762160a

Please sign in to comment.