feat: 优化跨平台路径解析并修复引号拼接 Bug
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,5 +8,6 @@ yarn.lock
|
|||||||
dist
|
dist
|
||||||
/temp
|
/temp
|
||||||
/arduino-cli
|
/arduino-cli
|
||||||
|
/arduino-libs
|
||||||
/bundle.cjs
|
/bundle.cjs
|
||||||
/nw_cache
|
/nw_cache
|
||||||
|
|||||||
35
package-lock.json
generated
35
package-lock.json
generated
@@ -811,6 +811,7 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.14.0.tgz",
|
"resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.14.0.tgz",
|
||||||
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==",
|
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@@ -832,6 +833,7 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz",
|
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz",
|
||||||
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
|
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fast-deep-equal": "^3.1.1",
|
"fast-deep-equal": "^3.1.1",
|
||||||
"fast-json-stable-stringify": "^2.0.0",
|
"fast-json-stable-stringify": "^2.0.0",
|
||||||
@@ -1155,6 +1157,7 @@
|
|||||||
"url": "https://github.com/sponsors/ai"
|
"url": "https://github.com/sponsors/ai"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"caniuse-lite": "^1.0.30001669",
|
"caniuse-lite": "^1.0.30001669",
|
||||||
"electron-to-chromium": "^1.5.41",
|
"electron-to-chromium": "^1.5.41",
|
||||||
@@ -1229,20 +1232,6 @@
|
|||||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||||
"dev": true
|
"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": {
|
"node_modules/bytes": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.1.2.tgz",
|
"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.",
|
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.2.0",
|
"@eslint-community/eslint-utils": "^4.2.0",
|
||||||
"@eslint-community/regexpp": "^4.6.1",
|
"@eslint-community/regexpp": "^4.6.1",
|
||||||
@@ -4960,6 +4950,7 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz",
|
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz",
|
||||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
"fast-uri": "^3.0.1",
|
"fast-uri": "^3.0.1",
|
||||||
@@ -5996,20 +5987,6 @@
|
|||||||
"node": "^18 || ^20 || >= 21"
|
"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": {
|
"node_modules/util-deprecate": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"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",
|
"resolved": "https://registry.npmmirror.com/webpack/-/webpack-5.96.1.tgz",
|
||||||
"integrity": "sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA==",
|
"integrity": "sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/eslint-scope": "^3.7.7",
|
"@types/eslint-scope": "^3.7.7",
|
||||||
"@types/estree": "^1.0.6",
|
"@types/estree": "^1.0.6",
|
||||||
@@ -6115,6 +6093,7 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/webpack-cli/-/webpack-cli-5.1.4.tgz",
|
"resolved": "https://registry.npmmirror.com/webpack-cli/-/webpack-cli-5.1.4.tgz",
|
||||||
"integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==",
|
"integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discoveryjs/json-ext": "^0.5.0",
|
"@discoveryjs/json-ext": "^0.5.0",
|
||||||
"@webpack-cli/configtest": "^2.1.1",
|
"@webpack-cli/configtest": "^2.1.1",
|
||||||
|
|||||||
@@ -4,18 +4,34 @@ import fsExtra from 'fs-extra';
|
|||||||
|
|
||||||
|
|
||||||
function processConfig(data) {
|
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) {
|
for (let i in data.path) {
|
||||||
if (!data.path[i]) {
|
if (!data.path[i]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (typeof data.path[i] === 'string') {
|
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') {
|
} else if (typeof data.path[i] === 'object') {
|
||||||
for (let j in data.path[i]) {
|
for (let j in data.path[i]) {
|
||||||
if (typeof data.path[i][j] !== 'string') {
|
if (typeof data.path[i][j] !== 'string') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
data.path[i][j] = path.resolve(process.cwd(), data.path[i][j]);
|
data.path[i][j] = resolvePath(data.path[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default class ShellMicroPython extends Shell {
|
|||||||
async burn(config) {
|
async burn(config) {
|
||||||
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: `"${PYTHON.path.cli}" "${MICROPYTHON.path.esptool}`,
|
||||||
com: config.port
|
com: config.port
|
||||||
};
|
};
|
||||||
const command = MString.tpl(config.command, info);
|
const command = MString.tpl(config.command, info);
|
||||||
@@ -22,7 +22,7 @@ export default class ShellMicroPython extends Shell {
|
|||||||
async upload(config) {
|
async upload(config) {
|
||||||
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: `"${PYTHON.path.cli}" "${MICROPYTHON.path.ampy}`,
|
||||||
com: config.port
|
com: config.port
|
||||||
};
|
};
|
||||||
const command = MString.tpl(config.command, info);
|
const command = MString.tpl(config.command, info);
|
||||||
|
|||||||
Reference in New Issue
Block a user