UNPKG

yuey-cli

Version:

前端脚手架 JS VUE3 element plus...

32 lines (30 loc) 874 B
import fs from 'fs'; export const deleteFolder = (path) => { let files = []; if( fs.existsSync(path) ) { files = fs.readdirSync(path); files.forEach(function(file,index){ let curPath = path + "/" + file; if(fs.statSync(curPath).isDirectory()) { deleteFolder(curPath); } else { fs.unlinkSync(curPath); } }); fs.rmdirSync(path); } } export const fetchFloders = (path) => { let files = []; const floders = []; if( fs.existsSync(path) ) { files = fs.readdirSync(path); files.forEach(function(file, index){ let curPath = path + "/" + file; if(fs.statSync(curPath).isDirectory()) { floders.push(file); } }); } return floders; }