1 | #!/usr/bin/env node
|
2 | 'use strict';
|
3 | const updateNotifier = require('update-notifier');
|
4 | const meow = require('meow');
|
5 | const del = require('del');
|
6 |
|
7 | const cli = meow(`
|
8 | Usage
|
9 | $ de <path|glob> [...]
|
10 |
|
11 | Options
|
12 | -f, --force Allow deleting the current working directory and outside
|
13 | -d, --dry-run List what would be deleted instead of deleting
|
14 |
|
15 | Examples
|
16 | $ de unicorn.png rainbow.png
|
17 | $ de '*.png' '!unicorn.png'
|
18 | `, {
|
19 | string: ['_'],
|
20 | boolean: [
|
21 | 'force',
|
22 | 'dry-run'
|
23 | ],
|
24 | alias: {
|
25 | f: 'force',
|
26 | d: 'dry-run'
|
27 | }
|
28 | });
|
29 |
|
30 | updateNotifier({pkg: cli.pkg}).notify();
|
31 |
|
32 | if (cli.input.length === 0) {
|
33 | console.error('Specify at least one path');
|
34 | process.exit(1);
|
35 | }
|
36 |
|
37 | del(cli.input, cli.flags).then(files => {
|
38 | if (cli.flags.dryRun) {
|
39 | console.log(files.join('\n'));
|
40 | }
|
41 | });
|