function flush(callback) { // Perform the transformation var parsed, transformed, dictionary = util.merge(that.dict, process.env); try { parsed = JSON.parse(buffer.toString()); } catch(e) { // Return with an error callback return callback(e); } transformed = util.mapNested(parsed, function(val) { return util.substitute(val, dictionary); }); this.push(JSON.stringify(transformed)); // jshint ignore:line callback(); }
/** * Pass a configuration to configify. Returns a new instance of * configify, leaving the existing instance intact. * * Currently the only option to configure is the dictionary to use * for value substitutions that overrides environment variables. * * @alias module:browserify-configify.configure * @example * ```js * var options = { * dict: { HOME: '/home/configify' } * }; * var configured = configify.configure(options); * * b.transform(configured); * ``` * @param {Object} opts The configuration object to pass. * @return {Function} A new instance of configify, with the given options */ function configure(opts) { // Rebind the configy for new options var options = util.merge(opts, defaults); return configify.bind(options); }