From c4d03428e845d9ed47b3f240f5faca334c805375 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Sat, 12 Jul 2014 11:00:34 -0700 Subject: [PATCH] Defer to Utils#fetch for getting ENV state --- lib/config.js | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/lib/config.js b/lib/config.js index 5a1cca5..b55cea5 100644 --- a/lib/config.js +++ b/lib/config.js @@ -8,39 +8,8 @@ 'use strict'; -// Public: Fetches a variable from the environment, returning a provided value if -// it's not set. -// -// variable - variable to fetch from the environment -// defaultValue - value to return if the ENV variable isn't set -// -// Examples -// -// process.env["CYLON_TEST"] #=> undefined -// fetch("CYLON_TEST", "not set") -// #=> "not set" -// -// process.env["CYLON_TEST"] #=> false -// fetch("CYLON_TEST", true) -// #=> false -// -// process.env["CYLON_TEST"] #=> true -// fetch("CYLON_TEST", false) -// #=> true -// -// Returns the env var or default value -var fetch = function(variable, defaultValue) { - if (defaultValue == null) { - defaultValue = false; - } - - if (process.env[variable] != null) { - return process.env[variable]; - } else { - return defaultValue; - } -}; +var Utils = require('./utils'); module.exports = { - testing_mode: fetch('CYLON_TEST') + testing_mode: Utils.fetch(process.env, 'CYLON_TEST', false) };