From c0932196dd6846189ec82623c12d051eee799d4f Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Wed, 2 Aug 2017 16:56:22 -0700 Subject: [PATCH] get lib and cli to get version from package.json so bumping version isn't so much of a PITA --- Makefile | 2 -- bin/bunyan | 8 +++++--- lib/bunyan.js | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 1f32011..b7eec22 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,6 @@ all $(NODEUNIT): versioncheck: @echo version is: $(shell cat package.json | json version) [[ `cat package.json | json version` == `grep '^## ' CHANGES.md | head -2 | tail -1 | awk '{print $$2}'` ]] - [[ `cat package.json | json version` == `grep '^var VERSION' bin/bunyan | awk -F"'" '{print $$2}'` ]] - [[ `cat package.json | json version` == `grep '^var VERSION' lib/bunyan.js | awk -F"'" '{print $$2}'` ]] @echo Version check ok. .PHONY: cutarelease diff --git a/bin/bunyan b/bin/bunyan index a745a22..178f493 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -11,8 +11,6 @@ * vim: expandtab:ts=4:sw=4 */ -var VERSION = '2.0.1'; - var p = console.log; var util = require('util'); var pathlib = require('path'); @@ -134,8 +132,12 @@ var stdout = process.stdout; //---- support functions +var _version = null; function getVersion() { - return VERSION; + if (_version === null) { + _version = require('../package.json').version; + } + return _version; } diff --git a/lib/bunyan.js b/lib/bunyan.js index fa603a9..cc7ce5d 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -8,8 +8,6 @@ * vim: expandtab:ts=4:sw=4 */ -var VERSION = '2.0.1'; - /* * Bunyan log format version. This becomes the 'v' field on all log records. * This will be incremented if there is any backward incompatible change to @@ -1611,7 +1609,7 @@ module.exports.resolveLevel = resolveLevel; module.exports.levelFromName = levelFromName; module.exports.nameFromLevel = nameFromLevel; -module.exports.VERSION = VERSION; +module.exports.VERSION = require('../package.json').version; module.exports.LOG_VERSION = LOG_VERSION; module.exports.createLogger = function createLogger(options) {