(scriptName)
| 6 | |
| 7 | // 智能获取脚本路径(兼容开发和打包环境) |
| 8 | function getScriptPath(scriptName) { |
| 9 | // 开发时:__dirname 是 lib/,脚本在同目录 |
| 10 | let scriptPath = resolve(__dirname, scriptName) |
| 11 | if (fs.existsSync(scriptPath)) { |
| 12 | return scriptPath |
| 13 | } |
| 14 | // 打包后:__dirname 是 res/,脚本在 lib/ 子目录 |
| 15 | scriptPath = resolve(__dirname, "lib", scriptName) |
| 16 | if (fs.existsSync(scriptPath)) { |
| 17 | return scriptPath |
| 18 | } |
| 19 | // 回退 |
| 20 | return resolve(__dirname, scriptName) |
| 21 | } |
| 22 | |
| 23 | // 智能获取 node 可执行文件路径 |
| 24 | function getNodePath() { |