-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
48 lines (45 loc) · 1.41 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
#!/usr/bin/env node
const updateNotifier = require('update-notifier');
const c = require('chalk');
const {argv} = require('yargs')
.parserConfiguration({
'short-option-groups': true,
'camel-case-expansion': false,
'dot-notation': false,
'parse-numbers': true,
'boolean-negation': false
})
.usage('Usage: $0 <package-name> [other-package-names...]')
.describe('package', 'Provide a package.json to read dependencies')
.alias('package', 'p')
.string('package')
.describe('range', 'Get a range of version (0 for all, 8 by default)')
.alias('range', 'r')
.number('range')
.describe('json', 'Output json rather than a formater string')
.alias('json', 'j')
.boolean('j')
.describe('size', 'Output just the module size')
.alias('size', 's')
.boolean('s')
.describe('gzip-size', 'Output just the module gzip size')
.alias('gzip-size', 'g')
.boolean('g')
.describe('dependencies', 'Output just the number of dependencies')
.alias('dependencies', 'd')
.boolean('d')
.describe('self', 'Output bundle-phobia stats')
.boolean('self')
.help('h')
.alias('h', 'help')
.pkgConf('bundle-phobia');
const pkg = require('./package');
const {main} = require('./src/core');
if (!module.parent) {
/* eslint-disable no-console */
main({argv}).catch(err => {
console.log(c.red.bold('bundle-phobia failed: ') + err.message);
process.exit(1);
});
updateNotifier({pkg}).notify();
}