!893 unify file separator of each system for error message

Merge pull request !893 from yfwang6/pathexpect
This commit is contained in:
openharmony_ci
2022-08-02 08:54:00 +00:00
committed by Gitee
2 changed files with 13 additions and 8 deletions
+9 -5
View File
@@ -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) {
@@ -102,11 +102,13 @@ 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 {
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;
}
}
@@ -150,7 +152,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 +219,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;
}
});
}
+4 -3
View File
@@ -350,7 +350,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');
@@ -372,10 +372,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);