change logic of @Entry&@Preview

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: Ic2c994ed6dce60d765f9d702e2442b1a015d60d1
This commit is contained in:
houhaoyu
2022-02-16 16:39:28 +08:00
parent c2a35fa1fd
commit 4e526a4d3e
2 changed files with 6 additions and 4 deletions
+5 -4
View File
@@ -190,14 +190,15 @@ function checkComponentDecorator(source: string, filePath: string,
BUILDIN_STYLE_NAMES.add(item.name.getText());
}
});
validateEntryAndPreviewCount(result, fileQuery, sourceFile.fileName, projectConfig.isPreview, log);
validateEntryAndPreviewCount(result, fileQuery, sourceFile.fileName, projectConfig.isPreview,
!!projectConfig.checkEntry, log);
}
return log.length ? log : null;
}
function validateEntryAndPreviewCount(result: DecoratorResult, fileQuery: string,
fileName: string, isPreview: boolean, log: LogInfo[]): void {
fileName: string, isPreview: boolean, checkEntry: boolean, log: LogInfo[]): void {
if (result.previewCount > 10 && fileQuery === '?entry') {
log.push({
type: LogType.ERROR,
@@ -212,7 +213,7 @@ function validateEntryAndPreviewCount(result: DecoratorResult, fileQuery: string
fileName: fileName
});
}
if (isPreview && result.previewCount < 1 && result.entryCount !== 1 &&
if (isPreview && !checkEntry && result.previewCount < 1 && result.entryCount !== 1 &&
fileQuery === '?entry') {
log.push({
type: LogType.ERROR,
@@ -220,7 +221,7 @@ function validateEntryAndPreviewCount(result: DecoratorResult, fileQuery: string
+ `decorator, or at least one '@Preview' decorator.`,
fileName: fileName
});
} else if (!isPreview && result.entryCount !== 1 && fileQuery === '?entry') {
} else if ((!isPreview || isPreview && checkEntry) && result.entryCount !== 1 && fileQuery === '?entry') {
log.push({
type: LogType.ERROR,
message: `A page configured in 'config.json' must have one and only one '@Entry' `
+1
View File
@@ -242,6 +242,7 @@ module.exports = (env, argv) => {
}
} else {
projectConfig.isPreview = true;
projectConfig.checkEntry = env.checkEntry;
let port;
process.argv.forEach((val, index) => {
if(val.startsWith('port=')){