feat(bin): adds version flag

adds --version / -v support for the nuxt binary; will always output version and exit(0)
This commit is contained in:
Eric McCormick 2017-10-12 22:48:20 -05:00 committed by Pooya Parsa
parent cf693d04a3
commit a5e16d2fe6

View File

@ -10,7 +10,9 @@ const fs = require('fs')
const parseArgs = require('minimist')
const { Nuxt, Builder } = require('../')
const chokidar = require('chokidar')
const resolve = require('path').resolve
const path = require('path')
const resolve = path.resolve
const pkg = require(path.join('..','package.json'))
const argv = parseArgs(process.argv.slice(2), {
alias: {
@ -19,15 +21,21 @@ const argv = parseArgs(process.argv.slice(2), {
p: 'port',
c: 'config-file',
s: 'spa',
u: 'universal'
u: 'universal',
v: 'version'
},
boolean: ['h', 's', 'u'],
boolean: ['h', 's', 'u', 'v'],
string: ['H', 'c'],
default: {
c: 'nuxt.config.js'
}
})
if(argv.version){
console.log(pkg.version)
process.exit(0)
}
if (argv.hostname === '') {
console.error(`> Provided hostname argument has no value`)
process.exit(1)