From 2ca0c5ca2274abdb6533bb00068c5336ee3fef2f Mon Sep 17 00:00:00 2001 From: Zachary Carter <zack.carter@gmail.com> Date: Tue, 17 Jul 2012 17:10:32 -0700 Subject: [PATCH] Only warn about ver.txt if in production - issue #928 --- lib/version.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/version.js b/lib/version.js index 25effa9ed..f46ae9fab 100644 --- a/lib/version.js +++ b/lib/version.js @@ -12,23 +12,26 @@ fs = require('fs'), path = require('path'), logger = require('./logging.js').logger, spawn = require('child_process').spawn, -secrets = require('./secrets.js'); +secrets = require('./secrets.js'), +config = require('./configuration'); var sha; // first try ver.txt which by convention is placed in repo root at // deployment time -try { - var contents = fs.readFileSync(path.join(__dirname, '..', 'resources', 'static', 'ver.txt')); - sha = contents.toString().split(' ')[0]; - if (sha.length != 7) throw "bad sha in ver.txt"; -} catch(e) { - sha = undefined; - logger.debug('cannot read code version from ver.txt: ' + e); +if (config.get('env') === 'production') { + try { + var contents = fs.readFileSync(path.join(__dirname, '..', 'resources', 'static', 'ver.txt')); + sha = contents.toString().split(' ')[0]; + if (sha.length != 7) throw "bad sha in ver.txt"; + } catch(e) { + sha = undefined; + logger.debug('cannot read code version from ver.txt: ' + e); + } } // now set the SHA to either the read SHA or a random string -module.exports = function() { return sha; } +module.exports = function() { return sha; }; // if ver.txt discovery failed, try using git to get the sha. if (!sha) { -- GitLab