diff --git a/compiler/src/gen_abc.ts b/compiler/src/gen_abc.ts index 055fa13..13b0e78 100644 --- a/compiler/src/gen_abc.ts +++ b/compiler/src/gen_abc.ts @@ -18,6 +18,10 @@ import * as process from 'process'; import * as fs from 'fs'; import cluster from 'cluster'; import { logger } from './compile_info'; +import { + SUCCESS, + FAIL +} from './pre_define' const red: string = '\u001b[31m'; const reset: string = '\u001b[39m'; @@ -41,6 +45,7 @@ function js2abcByWorkers(jsonInput: string, cmd: string): Promise { fs.renameSync(abcFile, abcFileNew); } else { logger.error(red, `ETS:ERROR ${abcFile} is lost`, reset); + process.exit(FAIL); } } } @@ -50,5 +55,5 @@ logger.debug('gen_abc isWorker is: ', cluster.isWorker); if (cluster.isWorker && process.env['inputs'] !== undefined && process.env['cmd'] !== undefined) { logger.debug('==>worker #', cluster.worker.id, 'started!'); js2abcByWorkers(process.env['inputs'], process.env['cmd']); - process.exit(); + process.exit(SUCCESS); } diff --git a/compiler/src/gen_abc_plugin.ts b/compiler/src/gen_abc_plugin.ts index 448ed00..6e7d260 100644 --- a/compiler/src/gen_abc_plugin.ts +++ b/compiler/src/gen_abc_plugin.ts @@ -41,7 +41,9 @@ import { EXTNAME_MJS, EXTNAME_CJS, EXTNAME_D_TS, - EXTNAME_ABC + EXTNAME_ABC, + SUCCESS, + FAIL } from './pre_define'; const firstFileEXT: string = '_.js'; @@ -120,6 +122,7 @@ export class GenAbcPlugin { } else { if (!fs.existsSync(path.resolve(arkDir, 'build'))) { logger.error(red, 'ETS:ERROR find build fail', reset); + process.exitCode = FAIL; return; } } @@ -295,6 +298,7 @@ function handleFinishModules(modules, callback): any { processJsModule(filePath, tempFilePath, buildFilePath, nodeModulesFile, module); } else { logger.error(red, `ETS:ERROR Cannot find resolve this file path: ${filePath}`, reset); + process.exitCode = FAIL; } } }); @@ -329,6 +333,7 @@ function writeFileSync(inputString: string, output: string, jsBundleFile: string intermediateJsBundle.push({path: output, size: fileSize}); } else { logger.error(red, `ETS:ERROR Failed to convert file ${jsBundleFile} to bin. ${output} is lost`, reset); + process.exitCode = FAIL; } } @@ -463,10 +468,16 @@ function invokeCluterModuleToAbc(): void { } cluster.on('exit', (worker, code, signal) => { + if (code === FAIL) { + process.exitCode = FAIL; + } logger.debug(`worker ${worker.process.pid} finished`); }); process.on('exit', (code) => { + if (process.exitCode === FAIL) { + return; + } writeModuleHashJson(); }); } @@ -524,10 +535,16 @@ function invokeWorkersToGenAbc(): void { } cluster.on('exit', (worker, code, signal) => { + if (code === FAIL) { + process.exitCode = FAIL; + } logger.debug(`worker ${worker.process.pid} finished`); }); process.on('exit', (code) => { + if (process.exitCode === FAIL) { + return; + } writeHashJson(); }); } @@ -553,7 +570,8 @@ function filterIntermediateModuleByHashJson(buildPath: string, moduleInfos: Arra const abcPath: string = moduleInfos[i].abcFilePath; if (!fs.existsSync(input)) { logger.error(red, `ETS:ERROR ${input} is lost`, reset); - continue; + process.exitCode = FAIL; + break; } if (fs.existsSync(abcPath)) { const hashInputContentData: any = toHashData(input); @@ -585,7 +603,8 @@ function writeModuleHashJson(): void { const abcPath: string = filterModuleInfos[i].abcFilePath; if (!fs.existsSync(input) || !fs.existsSync(abcPath)) { logger.error(red, `ETS:ERROR ${input} is lost`, reset); - continue; + process.exitCode = FAIL; + break; } const hashInputContentData: any = toHashData(input); const hashAbcContentData: any = toHashData(abcPath); @@ -625,7 +644,8 @@ function filterIntermediateJsBundleByHashJson(buildPath: string, inputPaths: Fil const abcPath: string = input.replace(/_.js$/, EXTNAME_ABC); if (!fs.existsSync(input)) { logger.error(red, `ETS:ERROR ${input} is lost`, reset); - continue; + process.exitCode = FAIL; + break; } if (fs.existsSync(abcPath)) { const hashInputContentData: any = toHashData(input); @@ -671,7 +691,7 @@ function genHashJsonPath(buildPath: string): string { buildPath = toUnixPath(buildPath); if (process.env.cachePath) { if (!fs.existsSync(process.env.cachePath) || !fs.statSync(process.env.cachePath).isDirectory()) { - logger.error(red, `ETS:ERROR hash path does not exist`, reset); + logger.debug(red, `ETS:ERROR hash path does not exist`, reset); return ''; } return path.join(process.env.cachePath, hashFile); @@ -679,7 +699,7 @@ function genHashJsonPath(buildPath: string): string { const dataTmps: string[] = buildPath.split(ARK); const hashPath: string = path.join(dataTmps[0], ARK); if (!fs.existsSync(hashPath) || !fs.statSync(hashPath).isDirectory()) { - logger.error(red, `ETS:ERROR hash path does not exist`, reset); + logger.debug(red, `ETS:ERROR hash path does not exist`, reset); return ''; } return path.join(hashPath, hashFile); diff --git a/compiler/src/gen_module_abc.ts b/compiler/src/gen_module_abc.ts index ecc84b7..57362c5 100644 --- a/compiler/src/gen_module_abc.ts +++ b/compiler/src/gen_module_abc.ts @@ -17,6 +17,10 @@ import * as childProcess from 'child_process'; import * as process from 'process'; import cluster from 'cluster'; import { logger } from './compile_info'; +import { + SUCCESS, + FAIL +} from './pre_define' const red: string = '\u001b[31m'; const reset: string = '\u001b[39m'; @@ -35,7 +39,7 @@ function js2abcByWorkers(jsonInput: string, cmd: string): Promise { childProcess.execSync(singleCmd); } catch (e) { logger.error(red, `ETS:ERROR Failed to convert file ${inputsStr} to abc `, reset); - return; + process.exit(FAIL); } return; @@ -46,5 +50,5 @@ logger.debug('gen_abc isWorker is: ', cluster.isWorker); if (cluster.isWorker && process.env['inputs'] !== undefined && process.env['cmd'] !== undefined) { logger.debug('==>worker #', cluster.worker.id, 'started!'); js2abcByWorkers(process.env['inputs'], process.env['cmd']); - process.exit(); + process.exit(SUCCESS); } diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 1740949..06aabe9 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -252,3 +252,6 @@ export const EXTNAME_MJS: string = '.mjs'; export const EXTNAME_CJS: string = '.cjs'; export const EXTNAME_D_TS: string = '.d.ts'; export const EXTNAME_ABC: string = '.abc'; + +export const SUCCESS: number = 0; +export const FAIL: number = 1; \ No newline at end of file diff --git a/compiler/test/ut/render_decorator/@builderParam/@builderParam.ts b/compiler/test/ut/render_decorator/@builderParam/@builderParam.ts index edff8d5..fa65ee6 100644 --- a/compiler/test/ut/render_decorator/@builderParam/@builderParam.ts +++ b/compiler/test/ut/render_decorator/@builderParam/@builderParam.ts @@ -94,9 +94,7 @@ struct CustomContainerUser { } ` exports.expectResult = -`"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const TestComponent_1 = require("./test/pages/TestComponent"); +`import { CustomContainerExport } from './test/pages/TestComponent'; class CustomContainer extends View { constructor(compilerAssignedUniqueChildId, parent, params) { super(compilerAssignedUniqueChildId, parent); @@ -193,7 +191,7 @@ class CustomContainerUser extends View { Column.create(); let earlierCreatedChild_2 = this.findChildById("2"); if (earlierCreatedChild_2 == undefined) { - View.create(new TestComponent_1.CustomContainerExport("2", this, { + View.create(new CustomContainerExport("2", this, { header: this.text, closer: () => { Column.create(); diff --git a/compiler/test/ut/ui_state_management/application_state_management/@storageLink/@storageLink.ts b/compiler/test/ut/ui_state_management/application_state_management/@storageLink/@storageLink.ts index e1decee..24e1600 100644 --- a/compiler/test/ut/ui_state_management/application_state_management/@storageLink/@storageLink.ts +++ b/compiler/test/ut/ui_state_management/application_state_management/@storageLink/@storageLink.ts @@ -53,8 +53,8 @@ let envLang = AppStorage.Prop('languageCode'); class MyComponent extends View { constructor(compilerAssignedUniqueChildId, parent, params) { super(compilerAssignedUniqueChildId, parent); - this.__varA = AppStorage.GetOrCreate().setAndLink("varA", 2, this); - this.__lang = AppStorage.GetOrCreate().setAndProp("languageCode", 'en', this); + this.__varA = AppStorage.GetOrCreate().setAndLink('varA', 2, this); + this.__lang = AppStorage.GetOrCreate().setAndProp('languageCode', 'en', this); this.label = 'count'; this.updateWithValueParams(params); } diff --git a/compiler/test/ut/ui_state_management/application_state_management/@storageProp/@storageProp.ts b/compiler/test/ut/ui_state_management/application_state_management/@storageProp/@storageProp.ts index e1decee..24e1600 100644 --- a/compiler/test/ut/ui_state_management/application_state_management/@storageProp/@storageProp.ts +++ b/compiler/test/ut/ui_state_management/application_state_management/@storageProp/@storageProp.ts @@ -53,8 +53,8 @@ let envLang = AppStorage.Prop('languageCode'); class MyComponent extends View { constructor(compilerAssignedUniqueChildId, parent, params) { super(compilerAssignedUniqueChildId, parent); - this.__varA = AppStorage.GetOrCreate().setAndLink("varA", 2, this); - this.__lang = AppStorage.GetOrCreate().setAndProp("languageCode", 'en', this); + this.__varA = AppStorage.GetOrCreate().setAndLink('varA', 2, this); + this.__lang = AppStorage.GetOrCreate().setAndProp('languageCode', 'en', this); this.label = 'count'; this.updateWithValueParams(params); } diff --git a/compiler/test/ut/ui_state_management/application_state_management/appStorage/appStorage.ts b/compiler/test/ut/ui_state_management/application_state_management/appStorage/appStorage.ts index e1decee..24e1600 100644 --- a/compiler/test/ut/ui_state_management/application_state_management/appStorage/appStorage.ts +++ b/compiler/test/ut/ui_state_management/application_state_management/appStorage/appStorage.ts @@ -53,8 +53,8 @@ let envLang = AppStorage.Prop('languageCode'); class MyComponent extends View { constructor(compilerAssignedUniqueChildId, parent, params) { super(compilerAssignedUniqueChildId, parent); - this.__varA = AppStorage.GetOrCreate().setAndLink("varA", 2, this); - this.__lang = AppStorage.GetOrCreate().setAndProp("languageCode", 'en', this); + this.__varA = AppStorage.GetOrCreate().setAndLink('varA', 2, this); + this.__lang = AppStorage.GetOrCreate().setAndProp('languageCode', 'en', this); this.label = 'count'; this.updateWithValueParams(params); }