Skip to content

Commit

Permalink
修复: 过滤文件夹内容为空时过滤所有文件夹bug;
Browse files Browse the repository at this point in the history
修复: 打开文件夹选择器时取消报错bug。
  • Loading branch information
LuckyHookin committed Feb 13, 2022
1 parent 2065205 commit 0dfe25a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 18 deletions.
Binary file modified dist/copyt.exe
Binary file not shown.
Binary file modified dist/copyt.zip
Binary file not shown.
21 changes: 15 additions & 6 deletions dist/res/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ const dir = process.argv[2];
// const dir = 'E:\\data\\web\\vue.js\\vue3\\hir';

// 文件类型过滤
const filterArg = process.argv[3];
let filterArg = process.argv[3];
// const filterArg = '\\.js|\\.vue';
if (filterArg==="*") {
filterArg = '.+';
}
const filter = new RegExp("("+filterArg+")$",'i');

// 文件夹过滤
const excludeArg = process.argv[4];
// const excludeArg = 'node_modules|dist';
const exclude = new RegExp(excludeArg,'i');
let exclude;
if (excludeArg!=='*') {
exclude = new RegExp(excludeArg,'i');
}

const codeFilePath = process.argv[5];
// const codeFilePath = './code.txt';
Expand All @@ -33,11 +39,14 @@ let api = new fdir().withFullPaths().filter(
// 文件类型过滤, true 则包含
return filter.test(path);
}
).exclude((dirName, dirPath) =>{
// console.log(dirName);
return exclude.test(dirName);
)
if (exclude) {
api = api.exclude((dirName="", dirPath) =>{
// console.log(dirName);
return exclude.test(dirName);
}
);
}
);

api.crawl(dir).withPromise().then((files) => {
for (let index = 0; index < files.length; index++) {
Expand Down
35 changes: 29 additions & 6 deletions main.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ button={cls="button";text="开始整理";left=512;top=144;right=584;bottom=176;d
button2={cls="button";text="停止整理";left=584;top=144;right=656;bottom=176;db=0.55;disabled=1;dr=1;z=1};
button3={cls="button";text="选择";left=64;top=96;right=104;bottom=112;ah=1;dl=1;font=LOGFONT(h=-9);z=12};
button4={cls="button";text="选择";left=64;top=152;right=104;bottom=168;ah=1;dl=1;font=LOGFONT(h=-9);z=13};
checkbox={cls="checkbox";text="过滤文件夹";left=232;top=8;right=320;bottom=24;checked=1;z=15};
codeFilePath={cls="edit";left=112;top=128;right=472;bottom=176;ah=1;autovscroll=false;dl=1;edge=1;hscroll=1;multiline=1;z=10};
dir={cls="edit";left=112;top=72;right=472;bottom=120;ah=1;autovscroll=false;dl=1;edge=1;hscroll=1;multiline=1;z=8};
excludeDir={cls="edit";text="node_modules|dist";left=304;top=8;right=472;bottom=56;ah=1;autohscroll=false;dl=1;edge=1;multiline=1;vscroll=1;z=6};
excludeDir={cls="edit";text="node_modules|dist";left=320;top=8;right=472;bottom=56;ah=1;autohscroll=false;dl=1;edge=1;multiline=1;vscroll=1;z=6};
fileType={cls="edit";text=".js|.vue|.jsx|.mjs|.ts";left=72;top=8;right=216;bottom=56;ah=1;autohscroll=false;dl=1;edge=1;multiline=1;vscroll=1;z=4};
richedit={cls="richedit";left=8;top=184;right=656;bottom=384;autohscroll=false;db=1;dl=1;dr=1;dt=0.47;edge=1;multiline=1;vscroll=1;z=14};
static={cls="static";text="文件类型";left=16;top=8;right=72;bottom=24;ah=1;dl=1;transparent=1;z=3};
static2={cls="static";text="过滤文件夹";left=232;top=8;right=304;bottom=24;ah=1;dl=1;transparent=1;z=5};
static2={cls="static";left=232;top=8;right=304;bottom=24;ah=1;dl=1;transparent=1;z=5};
static3={cls="static";text="欲处理项目路径";left=16;top=72;right=112;bottom=88;ah=1;dl=1;transparent=1;z=7};
static4={cls="static";text="汇总代码存放
路径";left=16;top=128;right=104;bottom=168;ah=1;dl=1;transparent=1;z=9};
Expand All @@ -34,8 +35,14 @@ mainForm.button.oncommand = function(id,event){
mainForm.button2.disabled=false;

var js = string.load("\res\index.js");

prcs = nodeJs.exec(js,mainForm.dir.text,mainForm.fileType.text,mainForm.excludeDir.text,mainForm.codeFilePath.text);
if(mainForm.fileType.text==""){
mainForm.fileType.text="*";
}
var excludeDir=mainForm.excludeDir.text;
if(excludeDir==""){
excludeDir="*";
}
prcs = nodeJs.exec(js,mainForm.dir.text,mainForm.fileType.text,excludeDir,mainForm.codeFilePath.text);

prcs.logResponse(function(v){
mainForm.richedit.log(v);
Expand All @@ -57,16 +64,32 @@ mainForm.button2.oncommand = function(id,event){


mainForm.button3.oncommand = function(id,event){
mainForm.dir.text = fsys.dlg.dir();
var dir = fsys.dlg.dir();
if(dir){
mainForm.dir.text = dir;
}
}

mainForm.button4.oncommand = function(id,event){
mainForm.codeFilePath.text = fsys.dlg.dir()++"\code.txt";
var dir = fsys.dlg.dir();
if(dir){
mainForm.codeFilePath.text = dir++"\code.txt";
}
}

mainForm.onClose = function(hwnd,message,wParam,lParam){
mainForm.button2.oncommand();
}

mainForm.checkbox.oncommand = function(id,event){
if(!mainForm.checkbox.checked){
mainForm.excludeDir.disabled = true;
mainForm.excludeDir.text="";
}else {
mainForm.excludeDir.disabled = false;
}

}

mainForm.show();
return win.loopMessage();
21 changes: 15 additions & 6 deletions res/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ const dir = process.argv[2];
// const dir = 'E:\\data\\web\\vue.js\\vue3\\hir';

// 文件类型过滤
const filterArg = process.argv[3];
let filterArg = process.argv[3];
// const filterArg = '\\.js|\\.vue';
if (filterArg==="*") {
filterArg = '.+';
}
const filter = new RegExp("("+filterArg+")$",'i');

// 文件夹过滤
const excludeArg = process.argv[4];
// const excludeArg = 'node_modules|dist';
const exclude = new RegExp(excludeArg,'i');
let exclude;
if (excludeArg!=='*') {
exclude = new RegExp(excludeArg,'i');
}

const codeFilePath = process.argv[5];
// const codeFilePath = './code.txt';
Expand All @@ -33,11 +39,14 @@ let api = new fdir().withFullPaths().filter(
// 文件类型过滤, true 则包含
return filter.test(path);
}
).exclude((dirName, dirPath) =>{
// console.log(dirName);
return exclude.test(dirName);
)
if (exclude) {
api = api.exclude((dirName="", dirPath) =>{
// console.log(dirName);
return exclude.test(dirName);
}
);
}
);

api.crawl(dir).withPromise().then((files) => {
for (let index = 0; index < files.length; index++) {
Expand Down

0 comments on commit 0dfe25a

Please sign in to comment.