1 | #!/usr/bin/env node
|
2 | const publish = require('./src/publish')
|
3 |
|
4 | const yargs = require('yargs')
|
5 | .option('dry-run', {
|
6 | describe: 'Print what will be done without doing it',
|
7 | type: 'boolean'
|
8 | })
|
9 | .option('dir', {
|
10 | describe: 'Path to the directory that contains the package.json to publish',
|
11 | type: 'string',
|
12 | default: '.'
|
13 | })
|
14 | .alias('help', 'h')
|
15 |
|
16 | const options = yargs.argv
|
17 |
|
18 | if (options.help) {
|
19 | yargs.showHelp()
|
20 | process.exit(0)
|
21 | }
|
22 |
|
23 | const npmArgs = options._
|
24 | delete options._
|
25 |
|
26 | console.warn(`[publish] options: ${JSON.stringify(options, null, 2)}`)
|
27 | console.warn(`[publish] npm args: ${JSON.stringify(npmArgs, null, 2)}`)
|
28 |
|
29 | publish(options, npmArgs)
|
30 | .then(context => {
|
31 | console.warn(`published! ${JSON.stringify(context, null, 2)}`)
|
32 | })
|
33 | .catch(error => {
|
34 | console.error(error)
|
35 | process.exitCode = 1
|
36 | })
|