fix(scripts): 修复路径不存在提示和打开目录延迟问题
1. 为路径不存在的情况添加专属警告日志 2. 给打开文件目录操作增加2秒延迟,适配部分系统文件操作节奏
This commit is contained in:
@@ -98,6 +98,7 @@ async function main() {
|
|||||||
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
||||||
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir, 'mp-harmony');
|
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir, 'mp-harmony');
|
||||||
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
||||||
|
|
||||||
await openFileDirectory(zipFilePath);
|
await openFileDirectory(zipFilePath);
|
||||||
} else {
|
} else {
|
||||||
console.log('跳过创建 ZIP 文件和打开目录');
|
console.log('跳过创建 ZIP 文件和打开目录');
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ function checkPathExists(targetPath) {
|
|||||||
fs.accessSync(targetPath);
|
fs.accessSync(targetPath);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.code === 'ENOENT') {
|
||||||
|
console.warn(`❌ 路径:${targetPath} 不存在!!`)
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,6 +254,7 @@ async function openFileDirectory(filePath, options = {}) {
|
|||||||
createIfNotExists = false, // 目录不存在时是否创建
|
createIfNotExists = false, // 目录不存在时是否创建
|
||||||
wait = false // 是否等待进程结束
|
wait = false // 是否等待进程结束
|
||||||
} = options;
|
} = options;
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 检查路径是否存在
|
// 检查路径是否存在
|
||||||
|
|||||||
Reference in New Issue
Block a user