From 2bb76be945e53b9a816f9d0a675125bea3cf9b46 Mon Sep 17 00:00:00 2001 From: WongXX Date: Sun, 26 May 2024 02:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=BE=A9=E8=B7=A8=E7=9B=A4=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=BE=A9=E8=A3=BD=E6=96=87=E4=BB=B6=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e907177..8c98aec 100644 --- a/index.js +++ b/index.js @@ -25,11 +25,18 @@ async function main() { Object.keys(objects).forEach(element => { let hash = objects[element].hash; + let srcfilepath = join(srcpath, hash.substring(0, 2), hash); let distfilepath = join(distpath, element); + if (!fs.existsSync(distfilepath)) { fs.mkdirSync(dirname(distfilepath), { recursive: true }); } - fs.renameSync(join(srcpath, hash.substring(0, 2), hash), distfilepath); + + if (fs.existsSync(srcfilepath)) { + fs.copyFileSync(srcfilepath, distfilepath); + } else { + console.log(`文件不存在:${srcfilepath}`) + } }); }