fix(shell-arduino): 改用 execFileUntilClosed 避免 shell 引号解析问题
This commit is contained in:
@@ -12,50 +12,56 @@ export default class ShellArduino extends Shell {
|
||||
let arduino = _.merge({}, ARDUINO);
|
||||
arduino = _.merge(arduino, config);
|
||||
|
||||
// 为每个 library 路径生成单独的 --library 参数
|
||||
const libraryArgs = arduino.path.libraries
|
||||
.map(lib => `--library "${lib}"`)
|
||||
.join(' ');
|
||||
|
||||
const command = [
|
||||
`"${arduino.path.cli}"`,
|
||||
// 构建参数数组,避免 shell 解析引号问题
|
||||
const args = [
|
||||
'compile',
|
||||
'-b', arduino.key,
|
||||
'--config-file', `"${arduino.path.config}"`,
|
||||
'--verbose',
|
||||
libraryArgs,
|
||||
'--build-path', `"${arduino.path.build}"`,
|
||||
'--output-dir', `"${arduino.path.output}"`,
|
||||
`"${arduino.path.code}"`,
|
||||
'--config-file', arduino.path.config,
|
||||
'--verbose'
|
||||
];
|
||||
|
||||
// 为每个 library 路径添加参数
|
||||
for (const lib of arduino.path.libraries) {
|
||||
args.push('--library', lib);
|
||||
}
|
||||
|
||||
args.push(
|
||||
'--build-path', arduino.path.build,
|
||||
'--output-dir', arduino.path.output,
|
||||
arduino.path.code,
|
||||
'--no-color'
|
||||
].join(' ');
|
||||
console.log('DEBUG ARDUINO COMPILE CMD:', command);
|
||||
return this.execUntilClosed(command, { maxBuffer: 4096 * 1000000 });
|
||||
);
|
||||
|
||||
console.log('DEBUG ARDUINO COMPILE:', arduino.path.cli, args);
|
||||
return this.execFileUntilClosed(arduino.path.cli, args, { maxBuffer: 4096 * 1000000 });
|
||||
}
|
||||
|
||||
async upload(config) {
|
||||
let arduino = _.merge({}, ARDUINO);
|
||||
arduino = _.merge(arduino, config);
|
||||
|
||||
// 为每个 library 路径生成单独的 --library 参数
|
||||
const libraryArgs = arduino.path.libraries
|
||||
.map(lib => `--library "${lib}"`)
|
||||
.join(' ');
|
||||
|
||||
const command = [
|
||||
`"${arduino.path.cli}"`,
|
||||
// 构建参数数组,避免 shell 解析引号问题
|
||||
const args = [
|
||||
'compile',
|
||||
'--upload',
|
||||
'-p', arduino.port,
|
||||
'-b', arduino.key,
|
||||
'--config-file', `"${arduino.path.config}"`,
|
||||
'--verbose',
|
||||
libraryArgs,
|
||||
'--build-path', `"${arduino.path.build}"`,
|
||||
'--output-dir', `"${arduino.path.output}"`,
|
||||
`"${arduino.path.code}"`,
|
||||
'--config-file', arduino.path.config,
|
||||
'--verbose'
|
||||
];
|
||||
|
||||
// 为每个 library 路径添加参数
|
||||
for (const lib of arduino.path.libraries) {
|
||||
args.push('--library', lib);
|
||||
}
|
||||
|
||||
args.push(
|
||||
'--build-path', arduino.path.build,
|
||||
'--output-dir', arduino.path.output,
|
||||
arduino.path.code,
|
||||
'--no-color'
|
||||
].join(' ');
|
||||
return this.execUntilClosed(command, { maxBuffer: 4096 * 1000000 });
|
||||
);
|
||||
|
||||
return this.execFileUntilClosed(arduino.path.cli, args, { maxBuffer: 4096 * 1000000 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user