main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100755
|
File size:
912 bytes
|
Rev | Line | |
---|
[d565449] | 1 | #!/usr/bin/env node
|
---|
| 2 |
|
---|
| 3 | let { readFileSync } = require('fs')
|
---|
| 4 | let { join } = require('path')
|
---|
| 5 |
|
---|
| 6 | require('./check-npm-version')
|
---|
| 7 | let updateDb = require('./')
|
---|
| 8 |
|
---|
| 9 | const ROOT = __dirname
|
---|
| 10 |
|
---|
| 11 | function getPackage() {
|
---|
| 12 | return JSON.parse(readFileSync(join(ROOT, 'package.json')))
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | let args = process.argv.slice(2)
|
---|
| 16 |
|
---|
| 17 | let USAGE = 'Usage:\n npx update-browserslist-db\n'
|
---|
| 18 |
|
---|
| 19 | function isArg(arg) {
|
---|
| 20 | return args.some(i => i === arg)
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | function error(msg) {
|
---|
| 24 | process.stderr.write('update-browserslist-db: ' + msg + '\n')
|
---|
| 25 | process.exit(1)
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | if (isArg('--help') || isArg('-h')) {
|
---|
| 29 | process.stdout.write(getPackage().description + '.\n\n' + USAGE + '\n')
|
---|
| 30 | } else if (isArg('--version') || isArg('-v')) {
|
---|
| 31 | process.stdout.write('browserslist-lint ' + getPackage().version + '\n')
|
---|
| 32 | } else {
|
---|
| 33 | try {
|
---|
| 34 | updateDb()
|
---|
| 35 | } catch (e) {
|
---|
| 36 | if (e.name === 'BrowserslistUpdateError') {
|
---|
| 37 | error(e.message)
|
---|
| 38 | } else {
|
---|
| 39 | throw e
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.