From bf922a8fbdf69a46a2036642c53aca48689d5e68 Mon Sep 17 00:00:00 2001 From: yfwang6 Date: Mon, 1 Aug 2022 15:59:28 +0800 Subject: [PATCH 1/3] wangyongfei6@huawei.com unify file separator of each system for error message Signed-off-by: yfwang6 Change-Id: I974540084fae443b3cd0a085c808f6c707d6975e --- compiler/main.js | 9 ++++++--- compiler/src/compile_info.ts | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index 0ab8948..727304a 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -102,7 +102,8 @@ function loadEntryObj(projectConfig) { if (fs.existsSync(fileName)) { projectConfig.entryObj['./' + sourcePath] = fileName + '?entry'; } else { - throw Error(`\u001b[31m ERROR: page '${fileName}' does not exist. \u001b[39m`).message; + throw Error(`\u001b[31m ERROR: page '${fileName.replace(/\\/g, '/')}' does not exist. \u001b[39m`) + .message; } }); } else { @@ -150,7 +151,7 @@ function setEntryFile(projectConfig) { const entryFilePath = path.resolve(projectConfig.projectPath, entryFileRealPath); abilityConfig.abilityEntryFile = entryFilePath; if (!fs.existsSync(entryFilePath) && aceCompileMode === 'page') { - throw Error(`\u001b[31m ERROR: missing ${entryFilePath}. \u001b[39m`).message; + throw Error(`\u001b[31m ERROR: missing ${entryFilePath.replace(/\\/g, '/')}. \u001b[39m`).message; } projectConfig.entryObj[`./${entryFileName}`] = entryFilePath + '?entry'; } @@ -217,7 +218,9 @@ function setAbilityFile(projectConfig, abilityPages) { abilityConfig.projectAbilityPath.push(projectAbilityPath); projectConfig.entryObj[entryPageKey] = projectAbilityPath + '?entry'; } else { - throw Error(`\u001b[31m ERROR: srcEntrance file '${projectAbilityPath}' does not exist. \u001b[39m`).message; + throw Error( + `\u001b[31m ERROR: srcEntrance file '${projectAbilityPath.replace(/\\/g, '/')}' does not exist. \u001b[39m` + ).message; } }); } diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index a404124..707efdc 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -338,7 +338,7 @@ export class ResultStates { const position: string = errors[index].issue.location ? `:${errors[index].issue.location.start.line}:${errors[index].issue.location.start.column}` : ''; - const location: string = errors[index].issue.file + position; + const location: string = errors[index].issue.file.replace(/\\/g, '/') + position; const detail: string = errors[index].issue.message; logger.error(this.red, 'ETS:ERROR File: ' + location, this.reset); logger.error(this.red, detail, this.reset, '\n'); @@ -352,7 +352,7 @@ export class ResultStates { .replace(/\u001b\[.*?m/g, '').replace(/\.ets\.ts/g, '.ets').trim()}\n`; errorMessage = this.filterModuleError(errorMessage) .replace(/^ERROR in /, 'ETS:ERROR File: ').replace(/\s{6}TS/g, ' TS') - .replace(/\(([0-9]+),([0-9]+)\)/, ':$1:$2'); + .replace(/\(([0-9]+),([0-9]+)\)/, ':$1:$2').replace(/\\/g, '/'); this.printErrorMessage(errorMessage, false, errors[index]); } } From a39dc24a96ca2f11884718d4bbcc528270f6ecf0 Mon Sep 17 00:00:00 2001 From: yfwang6 Date: Mon, 1 Aug 2022 17:11:17 +0800 Subject: [PATCH 2/3] wangyongfei6@huawei.com unify file separator of each system for error message Signed-off-by: yfwang6 Change-Id: I200f1a4417084790c752554226e0a6c53e1afe7f --- compiler/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index 727304a..6d20be4 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -91,7 +91,7 @@ function loadEntryObj(projectConfig) { process.env.compileMode = 'moduleJson'; buildManifest(manifest, projectConfig.aceModuleJsonPath); } else { - throw Error('\u001b[31m ERROR: the manifest file ' + projectConfig.manifestFilePath + + throw Error('\u001b[31m ERROR: the manifest file ' + projectConfig.manifestFilePath.replace(/\\/g, '/') + ' or module.json is lost or format is invalid. \u001b[39m').message; } if (manifest.pages) { @@ -107,7 +107,8 @@ function loadEntryObj(projectConfig) { } }); } else { - throw Error('\u001b[31m ERROR: missing pages attribute in ' + projectConfig.manifestFilePath + + throw Error('\u001b[31m ERROR: missing pages attribute in ' + + projectConfig.manifestFilePath.replace(/\\/g, '/') + '. \u001b[39m').message; } } From 82c46d4c9cc31077f0578d68b61001e3e5ca4beb Mon Sep 17 00:00:00 2001 From: yfwang6 Date: Tue, 2 Aug 2022 09:31:55 +0800 Subject: [PATCH 3/3] wangyongfei6@huawei.com unify file separator of each system for error message Signed-off-by: yfwang6 Change-Id: Ia6da8a7a031fbdf01c65b89ffbee1a2a74bc238b --- compiler/src/compile_info.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 707efdc..f7c23a2 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -352,7 +352,7 @@ export class ResultStates { .replace(/\u001b\[.*?m/g, '').replace(/\.ets\.ts/g, '.ets').trim()}\n`; errorMessage = this.filterModuleError(errorMessage) .replace(/^ERROR in /, 'ETS:ERROR File: ').replace(/\s{6}TS/g, ' TS') - .replace(/\(([0-9]+),([0-9]+)\)/, ':$1:$2').replace(/\\/g, '/'); + .replace(/\(([0-9]+),([0-9]+)\)/, ':$1:$2'); this.printErrorMessage(errorMessage, false, errors[index]); } } @@ -360,10 +360,11 @@ export class ResultStates { } private printErrorMessage(errorMessage: string, lineFeed: boolean, errorInfo: Info): void { if (this.validateError(errorMessage)) { + const formatErrMsg = errorMessage.replace(/\\/g, '/'); if (lineFeed) { - logger.error(this.red, errorMessage + '\n', this.reset); + logger.error(this.red, formatErrMsg + '\n', this.reset); } else { - logger.error(this.red, errorMessage, this.reset); + logger.error(this.red, formatErrMsg, this.reset); } } else { const errorsIndex = this.mStats.compilation.errors.indexOf(errorInfo);