From a5e16d2fe610141a84dc164b5710688958f9b4d7 Mon Sep 17 00:00:00 2001 From: Eric McCormick Date: Thu, 12 Oct 2017 22:48:20 -0500 Subject: [PATCH] feat(bin): adds version flag adds --version / -v support for the nuxt binary; will always output version and exit(0) --- bin/nuxt-dev | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 488d3970c2..321a1fce5a 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -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)