diff --git a/compiler/main.js b/compiler/main.js index 58e8c3b..edd1013 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) { @@ -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; } }); } diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 8ac58dd..0edc17c 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -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);