-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (43 loc) · 1.5 KB
/
index.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
50
51
52
53
54
55
#!/usr/bin/env node
'use strict';
const {program} = require('commander');
const pkg = require('./package.json');
const {banner} = require('./lib/banner');
const {getLogger} = require('./lib/logger');
program
.name('banner-cli')
.description(pkg.description)
.version(pkg.version);
program
.argument('[source]', 'Files to bannerize');
program
.option('-n, --name <name>', 'override project name')
.option('-t, --tag <tag>', 'override tag version')
.option('-s, --site <site>', 'override homepage')
.option('-a, --author <author>', 'override author')
.option('-y, --year <year>', 'override year')
.option('--template <template>', 'override template')
.option('-l, --license <license>', 'override license')
.option('-d, --debug', 'debug options and args')
.option('--dry-run', 'test the command, simulate without actually doing it');
program.addHelpText('after', `
Examples:
$ banner-cli 'dist/**/*.js'
$ banner-cli 'dist/**/*.css' --author 'Mr Developer' --license MIT --site https://project.js.org
$ banner-cli 'dist/**/*.css' --template '/*<br> [name]<br> [tag]<br> [site]<br> [author]<br> [year]<br> [license]<br> [time] */'
`);
program.showSuggestionAfterError();
program.parse();
const args = program.args;
const options = program.opts();
const logger = getLogger();
if (options.debug) {
logger.debug(args, options);
process.exit(0);
}
if (args.length === 0) {
program.help();
process.exit(0);
}
banner(args, options, logger);
process.exit(0);