Signed-off-by: lizhouze <lizhouze@huawei.com>
This commit is contained in:
lizhouze
2022-08-18 20:34:15 +08:00
parent 75fb061f5a
commit ab8b7bfed6
+23 -4
View File
@@ -17,6 +17,7 @@ const WebSocket = require('ws');
const ts = require('typescript');
const path = require('path');
const fs = require('fs');
const process = require('child_process');
const { processComponentChild } = require('../lib/process_component_build');
const { createWatchCompilerHost } = require('../lib/ets_checker');
@@ -39,6 +40,7 @@ const pluginCommandChannelMessageHandlers = {
'compileComponent': handlePluginCompileComponent,
'default': () => {}
};
const es2abcFilePath = path.join(__dirname, '../bin/ark/build-win/bin/es2abc');
let previewCacheFilePath;
const messages = [];
@@ -133,10 +135,27 @@ function handlePluginCompileComponent(jsonData) {
}
}
receivedMsg.data.log = log;
if (pluginSocket.readyState === WebSocket.OPEN){
compileStatus = true;
receivedMsg_ = receivedMsg;
responseToPlugin();
if (fs.existsSync(es2abcFilePath + '.exe') || fs.existsSync(es2abcFilePath)){
es2abc(receivedMsg);
}
}
function es2abc(receivedMsg) {
const cmd = es2abcFilePath + ' --base64Input ' +
Buffer.from(receivedMsg.data.script).toString('base64') + ' --base64Output';
try {
process.exec(cmd, (error, stdout, stderr) => {
if (stdout) {
receivedMsg.data.script = stdout;
} else {
receivedMsg.data.script = "";
}
compileStatus = true;
receivedMsg_ = receivedMsg;
responseToPlugin();
})
} catch (e) {
}
}