-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·54 lines (45 loc) · 1023 Bytes
/
cli.js
File metadata and controls
executable file
·54 lines (45 loc) · 1023 Bytes
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
50
51
52
53
54
#!/usr/bin/env node
'use strict';
const forceDel = require('force-del');
const meow = require('meow');
const plur = require('plur');
const updateNotifier = require('update-notifier');
const cli = meow(
`
Usage
$ force-del [<path|glob> ...]
Options
--cwd=<dir> Current working directory
--verbose List deleted files
Examples
$ force-del silly-faces.jpg
$ force-del '*.jpg' '!too-cute.jpg'
$ force-del foo --cwd=../bar
`,
{
flags: {
cwd: {
type: 'string',
},
verbose: {
type: 'boolean',
},
},
}
);
updateNotifier({ pkg: cli.pkg }).notify();
if (cli.input.length === 0) {
console.error('Specify at least one path');
process.exit(1);
}
forceDel(cli.input, cli.flags).then(files => {
if (cli.flags.verbose) {
console.log(files.join('\n'));
}
if (files.length === 0) {
console.log('No items deleted');
}
if (files.length > 0) {
console.log(`Deleted ${files.length} ${plur('item', files.length)}`);
}
});