修復創建文件夾時連文件名字也被創建

This commit is contained in:
WongXX 2024-05-26 02:06:34 +08:00
parent 20d035a5c6
commit c9ad4adfcc

View File

@ -1,5 +1,5 @@
import fs from "fs"
import { join } from "path"
import { join, dirname } from "path"
process.stdin.setEncoding("utf8");
@ -27,7 +27,7 @@ async function main() {
let hash = objects[element].hash;
let distfilepath = join(distpath, element);
if (!fs.existsSync(distfilepath)) {
fs.mkdirSync(distfilepath, { recursive: true });
fs.mkdirSync(dirname(distfilepath), { recursive: true });
}
fs.renameSync(join(srcpath, hash.substring(0, 2), hash), distfilepath);
});