-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhelper.mjs
executable file
·39 lines (35 loc) · 989 Bytes
/
helper.mjs
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
#!/usr/bin/env zx
// Using `yarn global add zx`, and make sure that `yarn global bin` is in your
// PATH env variable.
// The first 3 arguments is: node's path, zx's path and this file's path.
// Remove to get the really arguments.
const [node_path, zs_path, this_file_path, ...argv] = process.argv;
$.verbose = false;
if (argv.length === 1 && argv[0] === 'find_all_file') {
const ignore_regex = [
'.*/node_modules/.*',
'.*/\\.git/.*',
'.*/dist/.*',
'.*/yarn\\.lock',
'.*/package-lock\\.json',
];
await $`find . -type f ${(() => {
const result = [];
ignore_regex.forEach((value) => {
result.push('!');
result.push('-regex');
result.push(value);
});
return result;
})()}`.pipe(process.stdout);
} else {
console.log(
[
'Usage: ./helper.mjs <command>',
'',
'Command:',
' find_all_file Show all files of the pwd row by row.',
' help Show this message',
].join('\n'),
);
}