fix(shell-micropython): 系统命令不加引号,修复 Linux shell 解析错误

This commit is contained in:
yczpf2019
2026-01-24 20:09:06 +08:00
parent c32583e3f4
commit cc2a2714c3

View File

@@ -10,9 +10,14 @@ export default class ShellMicroPython extends Shell {
} }
async burn(config) { async burn(config) {
// 对系统命令(不含路径分隔符)不加引号,只对路径加引号
const pythonCmd = PYTHON.path.cli.includes('/') || PYTHON.path.cli.includes('\\')
? `"${PYTHON.path.cli}"`
: PYTHON.path.cli;
const info = { const info = {
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath), indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
esptool: `"${PYTHON.path.cli}" "${MICROPYTHON.path.esptool}"`, esptool: `${pythonCmd} "${MICROPYTHON.path.esptool}"`,
com: config.port, com: config.port,
baudrate: config.baudrate || "460800" baudrate: config.baudrate || "460800"
}; };
@@ -41,9 +46,14 @@ export default class ShellMicroPython extends Shell {
} }
console.log('Processed resetValue:', resetValue); console.log('Processed resetValue:', resetValue);
// 对系统命令(不含路径分隔符)不加引号,只对路径加引号
const pythonCmd = PYTHON.path.cli.includes('/') || PYTHON.path.cli.includes('\\')
? `"${PYTHON.path.cli}"`
: PYTHON.path.cli;
const info = { const info = {
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath), indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
ampy: `"${PYTHON.path.cli}" "${MICROPYTHON.path.ampy}"`, ampy: `${pythonCmd} "${MICROPYTHON.path.ampy}"`,
com: config.port, com: config.port,
reset: resetValue reset: resetValue
}; };