let fs = require('fs');
let join = require('path').join;
var path = require('path');
/**
*
* @param startPath 起始目录文件夹路径
* @returns {Array}
*/
function findSync(startPath) {
let result=[];
function finder(path) {
let files=fs.readdirSync(path);
files.forEach((val,index) => {
let fPath=join(path,val);
let stats=fs.statSync(fPath);
if(stats.isDirectory()) finder(fPath);
if(stats.isFile()) result.push(fPath);
});
}
finder(startPath);
return result;
}
let newJS = findSync('./new/js').map(item => item.match(/\\([^\\]+)\\?$/)[1]);
let newCss = findSync('./new/css').map(item => item.match(/\\([^\\]+)\\?$/)[1]);
let oldJS = findSync('./old/js').map(item => item.match(/\\([^\\]+)\\?$/)[1]);
let oldCss = findSync('./
nodejs 对比文件夹下文件并复制到新的文件夹中
最新推荐文章于 2024-06-10 09:44:35 发布