From 590e209b2ccfadf7ce80b6803b163d8e5b1c423e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Sat, 30 Jul 2022 14:49:13 +0800 Subject: [PATCH] =?UTF-8?q?fileUtils=20=E5=88=9B=E5=BB=BA=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E6=96=B9=E6=B3=95=E6=9B=B4=E6=96=B0=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E5=88=9B=E5=BB=BA=E5=BD=93=E5=89=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E4=B8=8A=E4=B8=80=E7=BA=A7=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/fileUtils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/fileUtils.js b/src/utils/fileUtils.js index 82aa0aa..b85863a 100644 --- a/src/utils/fileUtils.js +++ b/src/utils/fileUtils.js @@ -1,11 +1,13 @@ const fs = require('fs'); +const path = require('path'); const LATEST_DATA_ONLY = process.env.LATEST_DATA_ONLY == true; // 创建目录 async function createFolder(folderToCreate) { - let currentFolder = folderToCreate.replace(/\\/g, '/'); - let parentFolder = currentFolder.substring(0, currentFolder.lastIndexOf('/')); + let currentFolder = path.join(folderToCreate); + let parentFolder = path.join(currentFolder, '../'); + // console.log({ currentFolder: currentFolder, parentFolder: parentFolder }); if (!fs.existsSync(currentFolder)) { // 文件夹不存在,创建文件夹 createFolder(parentFolder); // 保证父级文件夹存在