-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
51 lines (40 loc) · 1.83 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
let path = require("path");
let fs = require("fs");
let zl_nodefs = require("./index");
let {
writeFile, //创建/写入文件
deleteFile,//删除文件夹/文件
readFileList,//读取目录树tree
readFileContent,//读取文件内容
addFileContent, //追加文件内容
copycutFiledir,//复制/剪切 文件/文件夹
util,
} = zl_nodefs;
// copycutFiledir({
// inputFileUrl: "./doctest2",
// outFileUrl: "./doctest",
// copyOrCut: "cut",
// showExeResult:false,
// rewrite:false
// })
// util.createDirsSync("./aaa/bbb/ccc/ddd")
// let res = writeFile({ path: path.resolve(".")+"/test2/test3/test8.txt", content: "helloworld", showExeResult: true });
// // 写入文件(windows)
// let dir0 = path.join(path.resolve("."), "aaa\\bbb\\ccc\\d\\test8.txt");
// writeFile({ path: "back66666/test.js", content: "helloworld", showExeResult: false });
// fs.writeFileSync(path.resolve(".")+"/test2/test3/test8.txt", "content");
// addFileContent({filePath:dir0, content:"你好"})
// let res = readFileContent({ filePath: dir0 });
// console.log("=====res====", res);
// writeFile({ path: dir0, content: "helloworld", showExeResult: false });
// deleteFile({ fileUrl: path.join(path.resolve("."), "doctest2"), flag: true,showExeResult:false});
var fileList = readFileList({
dirPath: "./testdocx",
ignoreList: ["node_modules", ".git"], //遇到node_modules目录时进行忽略
needTypes: [".docx"], //只读取".doc", ".docx" 类型文件
issortByNum:true,
// isfilterEmptyDir:true
// ignoreTypes:[".js",".doc"], //忽略".js",".doc"文件类型(如果needTypes存在,则以needTypes为准,会忽略ignoreTypes参数)
});
// console.log(JSON.stringify(fileList,null,4))
// util.asyncDelEmptyDir(fileList,{ msV: 1000, num: 2}); //默认连续2秒没有变化就认为执行完成