From d5aa1c6c8cdd386c23c7ce1c4407e5fd600fc942 Mon Sep 17 00:00:00 2001 From: yczpf2019 Date: Sat, 24 Jan 2026 16:02:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=B7=A8=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=B7=AF=E5=BE=84=E8=A7=A3=E6=9E=90=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=BC=95=E5=8F=B7=E6=8B=BC=E6=8E=A5=20Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + package-lock.json | 35 +++++++-------------------------- src/common/config.js | 20 +++++++++++++++++-- src/common/shell-micropython.js | 4 ++-- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 0ece01a8..867fea9d 100755 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ yarn.lock dist /temp /arduino-cli +/arduino-libs /bundle.cjs /nw_cache diff --git a/package-lock.json b/package-lock.json index 3fc25b41..65bd537f 100755 --- a/package-lock.json +++ b/package-lock.json @@ -811,6 +811,7 @@ "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.14.0.tgz", "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -832,6 +833,7 @@ "resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -1155,6 +1157,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001669", "electron-to-chromium": "^1.5.41", @@ -1229,20 +1232,6 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, - "node_modules/bufferutil": { - "version": "4.0.8", - "resolved": "https://registry.npmmirror.com/bufferutil/-/bufferutil-4.0.8.tgz", - "integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==", - "hasInstallScript": true, - "optional": true, - "peer": true, - "dependencies": { - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">=6.14.2" - } - }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.1.2.tgz", @@ -2020,6 +2009,7 @@ "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -4960,6 +4950,7 @@ "resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -5996,20 +5987,6 @@ "node": "^18 || ^20 || >= 21" } }, - "node_modules/utf-8-validate": { - "version": "6.0.5", - "resolved": "https://registry.npmmirror.com/utf-8-validate/-/utf-8-validate-6.0.5.tgz", - "integrity": "sha512-EYZR+OpIXp9Y1eG1iueg8KRsY8TuT8VNgnanZ0uA3STqhHQTLwbl+WX76/9X5OY12yQubymBpaBSmMPkSTQcKA==", - "hasInstallScript": true, - "optional": true, - "peer": true, - "dependencies": { - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">=6.14.2" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -6069,6 +6046,7 @@ "resolved": "https://registry.npmmirror.com/webpack/-/webpack-5.96.1.tgz", "integrity": "sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA==", "dev": true, + "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.6", @@ -6115,6 +6093,7 @@ "resolved": "https://registry.npmmirror.com/webpack-cli/-/webpack-cli-5.1.4.tgz", "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==", "dev": true, + "peer": true, "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.1", diff --git a/src/common/config.js b/src/common/config.js index e0621341..0910bc07 100755 --- a/src/common/config.js +++ b/src/common/config.js @@ -4,18 +4,34 @@ import fsExtra from 'fs-extra'; function processConfig(data) { + const resolvePath = (p) => { + if (!p || typeof p !== 'string') { + return p; + } + // 如果是系统命令(不含路径斜杠),不作为路径处理,直接返回原名 + if (!p.includes('/') && !p.includes('\\')) { + return p; + } + // 如果已经是绝对路径,则直接返回 + if (path.isAbsolute(p)) { + return p; + } + // 否则解析为相对于当前工作目录的路径 + return path.resolve(process.cwd(), p); + }; + for (let i in data.path) { if (!data.path[i]) { continue; } if (typeof data.path[i] === 'string') { - data.path[i] = path.resolve(process.cwd(), data.path[i]); + data.path[i] = resolvePath(data.path[i]); } else if (typeof data.path[i] === 'object') { for (let j in data.path[i]) { if (typeof data.path[i][j] !== 'string') { continue; } - data.path[i][j] = path.resolve(process.cwd(), data.path[i][j]); + data.path[i][j] = resolvePath(data.path[i][j]); } } } diff --git a/src/common/shell-micropython.js b/src/common/shell-micropython.js index 3c6349b6..81fb6080 100755 --- a/src/common/shell-micropython.js +++ b/src/common/shell-micropython.js @@ -12,7 +12,7 @@ export default class ShellMicroPython extends Shell { async burn(config) { const info = { indexPath: path.resolve(CLIENT_PATH, config.boardDirPath), - esptool: `${PYTHON.path.cli}" "${MICROPYTHON.path.esptool}`, + esptool: `"${PYTHON.path.cli}" "${MICROPYTHON.path.esptool}`, com: config.port }; const command = MString.tpl(config.command, info); @@ -22,7 +22,7 @@ export default class ShellMicroPython extends Shell { async upload(config) { const info = { indexPath: path.resolve(CLIENT_PATH, config.boardDirPath), - ampy: `${PYTHON.path.cli}" "${MICROPYTHON.path.ampy}`, + ampy: `"${PYTHON.path.cli}" "${MICROPYTHON.path.ampy}`, com: config.port }; const command = MString.tpl(config.command, info);