copy-direction
v1.0.0
Published
const copyFn = (agoPath, nowPath) => { //容错处理 if (!fs.existsSync(agoPath)) { console.log("您需要复制的文件夹不存在"); return; } if (fs.existsSync(nowPath)) { console.log("您可能已经复制完成!!!") return; } //创建新
Downloads
3
Readme
######复制文件夹 ######const fs = require("fs");
const copyFn = (agoPath, nowPath) => { //容错处理 if (!fs.existsSync(agoPath)) { console.log("您需要复制的文件夹不存在"); return; } if (fs.existsSync(nowPath)) { console.log("您可能已经复制完成!!!") return; } //创建新的文件夹 fs.mkdirSync(nowPath); fs.readdirSync(agoPath).forEach(item => { let ago = agoPath + "/" + item; let now = nowPath + "/" + item; if (fs.statSync(ago).isFile()) { fs.copyFileSync(ago, now); } else { copyFn(ago, now); } }) } module.exports = { copyFn, }