UNPKG

834 BJavaScriptView Raw
1#!/usr/bin/env node
2const publish = require('./src/publish')
3
4const 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
16const options = yargs.argv
17
18if (options.help) {
19 yargs.showHelp()
20 process.exit(0)
21}
22
23const npmArgs = options._
24delete options._
25
26console.warn(`[publish] options: ${JSON.stringify(options, null, 2)}`)
27console.warn(`[publish] npm args: ${JSON.stringify(npmArgs, null, 2)}`)
28
29publish(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 })