39 lines
1.4 KiB
JavaScript
Executable File
39 lines
1.4 KiB
JavaScript
Executable File
import path from 'node:path';
|
|
import Shell from './shell.js';
|
|
import MString from './mstring.js';
|
|
import { MICROPYTHON, PYTHON, CLIENT_PATH } from './config.js';
|
|
|
|
|
|
export default class ShellMicroPython extends Shell {
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
async burn(config) {
|
|
const info = {
|
|
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
|
|
esptool: `"${PYTHON.path.cli}" "${MICROPYTHON.path.esptool}"`,
|
|
com: config.port
|
|
};
|
|
// 兼容性处理:移除模板中可能存在的冗余引号
|
|
let cmdTemplate = config.command || "";
|
|
cmdTemplate = cmdTemplate.replace(/"{esptool}"/g, '{esptool}');
|
|
const command = MString.tpl(cmdTemplate, info);
|
|
console.log('DEBUG CMD BURN:', command);
|
|
return this.execUntilClosed(command);
|
|
}
|
|
|
|
async upload(config) {
|
|
const info = {
|
|
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
|
|
ampy: `"${PYTHON.path.cli}" "${MICROPYTHON.path.ampy}"`,
|
|
com: config.port
|
|
};
|
|
// 兼容性处理:移除模板中可能存在的冗余引号
|
|
let cmdTemplate = config.command || "";
|
|
cmdTemplate = cmdTemplate.replace(/"{ampy}"/g, '{ampy}');
|
|
const command = MString.tpl(cmdTemplate, info);
|
|
console.log('DEBUG CMD UPLOAD:', command);
|
|
return this.execUntilClosed(command);
|
|
}
|
|
} |