From b89477fedf323b3394b9d529548f04f0b65bfb57 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Tue, 6 Sep 2022 17:09:04 +0800 Subject: [PATCH] houhaoyu@huawei.com fix watchmode Signed-off-by: houhaoyu Change-Id: Ia39edbb87ac757b0a3780fd1c307cec8429c23ee --- compiler/src/compile_info.ts | 6 +++--- compiler/src/gen_abc_plugin.ts | 16 ++++++++-------- compiler/src/process_import.ts | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 9c547e5..aacd11b 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -281,7 +281,7 @@ export class ResultStates { } private shouldWriteChangedList(watchModifiedFiles: string[], watchRemovedFiles: string[]): boolean { - return projectConfig.compileMode === ESMODULE && process.env.watchMode && !projectConfig.isPreview && + return projectConfig.compileMode === ESMODULE && process.env.watchMode === 'true' && !projectConfig.isPreview && projectConfig.outChangedFileList && (watchRemovedFiles.length + watchModifiedFiles.length) && !(watchModifiedFiles.length === 1 && watchModifiedFiles[0] == projectConfig.projectPath); } @@ -372,13 +372,13 @@ export class ResultStates { if (this.noteCount > 0) { resultInfo += ` NOTE:${this.noteCount}`; } - if (result === 'SUCCESS ' && process.env.watchMode) { + if (result === 'SUCCESS ' && process.env.watchMode === 'true') { this.printPreviewResult(resultInfo); } else { logger.info(this.blue, 'COMPILE RESULT:' + result + `{${resultInfo}}`, this.reset); } } else { - if (process.env.watchMode) { + if (process.env.watchMode === 'true') { this.printPreviewResult(); } else { console.info(this.blue, 'COMPILE RESULT:SUCCESS ', this.reset); diff --git a/compiler/src/gen_abc_plugin.ts b/compiler/src/gen_abc_plugin.ts index f118c9c..36c47e4 100644 --- a/compiler/src/gen_abc_plugin.ts +++ b/compiler/src/gen_abc_plugin.ts @@ -205,7 +205,7 @@ export class GenAbcPlugin { function clearGlobalInfo() { // fix bug of multi trigger - if (!process.env.watchMode) { + if (process.env.watchMode !== 'true') { intermediateJsBundle = []; moduleInfos = []; } @@ -529,7 +529,7 @@ export function initAbcEnv() : string[] { } function invokeCluterModuleToAbc(): void { - if (process.env.watchMode) { + if (process.env.watchMode === 'true') { process.exitCode = SUCCESS; } filterIntermediateModuleByHashJson(buildPathInfo, moduleInfos); @@ -573,7 +573,7 @@ function invokeCluterModuleToAbc(): void { if (count_ === totalWorkerNumber) { writeModuleHashJson(); clearGlobalInfo(); - if (process.env.watchMode) { + if (process.env.watchMode === 'true') { console.info(blue, 'COMPILE RESULT:SUCCESS ', reset); } } @@ -657,7 +657,7 @@ function judgeModuleWorkersToGenAbc(callback): void { } function invokeWorkersToGenAbc(): void { - if (process.env.watchMode) { + if (process.env.watchMode === 'true') { process.exitCode = SUCCESS; } let cmdPrefix: string = ''; @@ -709,7 +709,7 @@ function invokeWorkersToGenAbc(): void { count_++; if (count_ === workerNumber) { // for preview of with incre compile - if (process.env.watchMode) { + if (process.env.watchMode === 'true') { processExtraAssetForBundle(); console.info(red, 'COMPILE RESULT:SUCCESS ', reset); } @@ -723,7 +723,7 @@ function invokeWorkersToGenAbc(): void { }); // for preview of without incre compile - if (workerNumber === 0 && process.env.watchMode) { + if (workerNumber === 0 && process.env.watchMode === 'true') { processExtraAssetForBundle(); } } @@ -816,7 +816,7 @@ function writeModuleHashJson(): void { return; } // fix bug of multi trigger - if (!process.env.watchMode || delayCount < 1) { + if (process.env.watchMode !== 'true' || delayCount < 1) { fs.writeFileSync(hashFilePath, JSON.stringify(moduleHashJsonObject)); } } @@ -892,7 +892,7 @@ function writeHashJson(): void { return; } // fix bug of multi trigger - if (!process.env.watchMode || delayCount < 1) { + if (process.env.watchMode !== 'true' || delayCount < 1) { fs.writeFileSync(hashFilePath, JSON.stringify(hashJsonObject)); } } diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index 6735b3e..b00fd69 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -192,7 +192,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause) && node.exportClause.elements) { node.exportClause.elements.forEach(item => { - if (process.env.watchMode) { + if (process.env.watchMode === 'true') { exportCollection.add((item.propertyName ? item.propertyName : item.name).escapedText.toString()); } if (item.name && ts.isIdentifier(item.name)) { @@ -222,7 +222,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP } if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) { - if (process.env.watchMode && node.exportClause && ts.isNamedExports(node.exportClause) && + if (process.env.watchMode === 'true' && node.exportClause && ts.isNamedExports(node.exportClause) && node.exportClause.elements) { node.exportClause.elements.forEach(item => { exportCollection.add((item.propertyName ? item.propertyName : item.name).escapedText.toString()); @@ -290,7 +290,7 @@ function collectSpecialFunctionNode(node: ts.FunctionDeclaration, asNameFromPare function isExportEntry(node: ts.ClassDeclaration, log: LogInfo[], entryCollection: Set, exportCollection: Set, defaultCollection: Set, fileResolvePath: string, sourceFile: ts.SourceFile): void { - if (process.env.watchMode && node && node.decorators) { + if (process.env.watchMode === 'true' && node && node.decorators) { let existExport: boolean = false; let existEntry: boolean = false; if (node.modifiers) {