function buildRpk(event) { var quickgameCmd = 'node ' + getQuickgameIndex(); Editor.log(Editor.T('oppo-runtime.rpk_installing')); //defalut debug cmd var cmcExec = `${quickgameCmd} cocoscreator`; //release cmd cmcExec += !useDebugKey ? ' release' : ''; //tiny cmd // cmcExec += RUNTIME_CONFIG.tinyPackageMode ? ' --small-pack' : ''; exec(`${cmcExec}`, { env: environmentPath, cwd: dirTarget }, (error, stdout, stderr) => { if (error) { // 判断node 未安装 if (stderr.indexOf("'node' ") !== -1 || stderr.indexOf("node: command not found") !== -1) { if (RUNTIME_CONFIG.npmPath) { event.reply(new Error(Editor.T('oppo-runtime.custom_npm_path_config_error'))); return; } Editor.Ipc.sendToWins('builder:events', 'npmPath-show'); var msg = isWindowsPlatform ? Editor.T('oppo-runtime.not_install_nodejs_windows_error') : Editor.T('oppo-runtime.not_install_nodejs_mac_error'); event.reply(new Error(msg)); return; } event.reply(new Error(Editor.T('oppo-runtime.rpk_install_fail') + error)); return; } var rpkfile = path.join(dirTarget, 'dist', RUNTIME_CONFIG.package + (!useDebugKey ? '.signed.' : '.') + 'rpk'); Editor.log(Editor.T('oppo-runtime.rpk_install_success') + rpkfile); copyResTiny(); event.reply(); sendStatistics(); }); }
按照思路修改完成之后,实现了想要的效果