mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
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:
parent
cf693d04a3
commit
a5e16d2fe6
14
bin/nuxt-dev
14
bin/nuxt-dev
@ -10,7 +10,9 @@ const fs = require('fs')
|
|||||||
const parseArgs = require('minimist')
|
const parseArgs = require('minimist')
|
||||||
const { Nuxt, Builder } = require('../')
|
const { Nuxt, Builder } = require('../')
|
||||||
const chokidar = require('chokidar')
|
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), {
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
alias: {
|
alias: {
|
||||||
@ -19,15 +21,21 @@ const argv = parseArgs(process.argv.slice(2), {
|
|||||||
p: 'port',
|
p: 'port',
|
||||||
c: 'config-file',
|
c: 'config-file',
|
||||||
s: 'spa',
|
s: 'spa',
|
||||||
u: 'universal'
|
u: 'universal',
|
||||||
|
v: 'version'
|
||||||
},
|
},
|
||||||
boolean: ['h', 's', 'u'],
|
boolean: ['h', 's', 'u', 'v'],
|
||||||
string: ['H', 'c'],
|
string: ['H', 'c'],
|
||||||
default: {
|
default: {
|
||||||
c: 'nuxt.config.js'
|
c: 'nuxt.config.js'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if(argv.version){
|
||||||
|
console.log(pkg.version)
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if (argv.hostname === '') {
|
if (argv.hostname === '') {
|
||||||
console.error(`> Provided hostname argument has no value`)
|
console.error(`> Provided hostname argument has no value`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user