diff --git a/compiler/npm-install.js b/compiler/npm-install.js index e8cc4a93706e1682dbf5eff71a1d89386867326a..fb691ef30bcc528656675cb0e374345058fc755c 100644 --- a/compiler/npm-install.js +++ b/compiler/npm-install.js @@ -18,29 +18,29 @@ const path = require('path'); const fs = require('fs'); const exec = require('child_process').exec; -if (!fs.existsSync(path.resolve(__dirname, 'bin', 'ark'))) { +const arkDir = path.resolve(__dirname, 'bin', "ark"); +if (!fs.existsSync(arkDir)) { return; } let isWin = !1; let isMac = !1; -if (fs.existsSync(path.resolve(__dirname, 'bin', 'ark/build-win'))) { +if (fs.existsSync(path.join(arkDir, "build"))) { isWin = !0; -} else if (fs.existsSync(path.resolve(__dirname, 'bin', 'ark/build-mac'))) { +} else if (fs.existsSync(path.join(arkDir, "build-win"))) { isMac = !0; -} else if (!fs.existsSync(path.resolve(__dirname, 'bin', 'ark/build'))) { - console.error('[31m', 'find build fail', '[39m'); - return; +} else if (!fs.existsSync(path.join(arkDir, "build-mac"))) { + throw Error("Error: find build fail").message; } let cwd; if (isWin) { - cwd = path.join(__dirname, 'bin', 'ark', 'build-win'); + cwd = path.join(arkDir, "build-win"); } else if (isMac) { - cwd = path.join(__dirname, 'bin', 'ark', 'build-mac'); + cwd = path.join(arkDir, "build-mac"); } else { - cwd = path.join(__dirname, 'bin', 'ark', 'build'); + cwd = path.join(arkDir, "build"); } exec('npm install', { cwd: cwd }, function(err, stdout, stderr) { diff --git a/compiler/src/gen_abc_plugin.ts b/compiler/src/gen_abc_plugin.ts index 9041ed22c01dd6a459ca7ce6737224eb3d87d801..7053b50fa499ef1c3a0d16c5d30d09bd65ab2c4c 100644 --- a/compiler/src/gen_abc_plugin.ts +++ b/compiler/src/gen_abc_plugin.ts @@ -20,7 +20,7 @@ import * as path from 'path'; import Compiler from 'webpack/lib/Compiler'; import { logger } from './compile_info'; -const pandaDir: string = path.join(__dirname, '..', 'bin', 'panda'); +const arkDir: string = path.join(__dirname, '..', 'bin', 'ark'); const forward: string = '(global.___mainEntry___ = function (globalObjects) {' + '\n' + ' var define = globalObjects.define;' + '\n' + @@ -54,13 +54,13 @@ export class GenAbcPlugin { isDebug = isDebug_; } apply(compiler: Compiler) { - if (fs.existsSync(path.resolve(webpackPath, 'panda/build-win'))) { + if (fs.existsSync(path.resolve(webpackPath, 'ark/build-win'))) { isWin = true; } else { - if (fs.existsSync(path.resolve(webpackPath, 'panda/build-mac'))) { + if (fs.existsSync(path.resolve(webpackPath, 'ark/build-mac'))) { isMac = true; } else { - if (!fs.existsSync(path.resolve(webpackPath, 'panda/build'))) { + if (!fs.existsSync(path.resolve(webpackPath, 'ark/build'))) { logger.error(red, 'ETS:ERROR find build fail', reset); return; } @@ -87,7 +87,7 @@ function writeFileSync(inputString: string, output: string, jsBundleFile: string } fs.writeFileSync(output, inputString); if (fs.existsSync(output)) { - ts2abcFirst(output); + js2abcFirst(output); } else { logger.error(red, `ETS:ERROR Failed to convert file ${jsBundleFile} to bin. ${output} is lost`, reset); } @@ -101,20 +101,20 @@ function mkDir(path_: string): void { fs.mkdirSync(path_); } -function ts2abcFirst(inputPath: string): void { +function js2abcFirst(inputPath: string): void { let param: string = '-r'; if (isDebug) { param += ' --debug'; } - let ts2abc: string = path.join(pandaDir, 'build', 'src', 'index.js'); + let js2abc: string = path.join(arkDir, 'build', 'src', 'index.js'); if (isWin) { - ts2abc = path.join(pandaDir, 'build-win', 'src', 'index.js'); + js2abc = path.join(arkDir, 'build-win', 'src', 'index.js'); } else if (isMac) { - ts2abc = path.join(pandaDir, 'build-mac', 'src', 'index.js'); + js2abc = path.join(arkDir, 'build-mac', 'src', 'index.js'); } - const cmd: string = `node --expose-gc "${ts2abc}" "${inputPath}" ${param}`; + const cmd: string = `node --expose-gc "${js2abc}" "${inputPath}" ${param}`; try { logger.info(blue, `ETS:INFO ${cmd}`, reset, '\n');