unify file separator of each system for error message

Signed-off-by: yfwang6 <wangyongfei6@huawei.com>
Change-Id: I974540084fae443b3cd0a085c808f6c707d6975e
This commit is contained in:
yfwang6
2022-08-01 15:59:28 +08:00
parent aa6ac86cde
commit bf922a8fbd
2 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -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;
}
});
}
+2 -2
View File
@@ -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]);
}
}