remove app.configure()
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Roman Shtylman · committed by Roman Shtylman · parent 8c05946 · Browse files · 2 files·+0 added−150 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+0 added−150 removed
- tests:+0 added−96 removed
- other:+0 added−54 removed
Provenance
- Commit
7282b50- Tree
a39ad49- Author
Roman Shtylman <shtylman@gmail.com>- Committer
Roman Shtylman <shtylman@gmail.com>- Parent
8c05946
2 files changed+0 added−150 removed
modified:lib/application.js-54 removed
333 unmodified lines334 return this.set(setting, false);335 };336 337 /**338- * Configure callback for zero or more envs,339- * when no `env` is specified that callback will340- * be invoked for all environments. Any combination341- * can be used multiple times, in any order desired.342- *343- * Examples:344- *345- * app.configure(function(){346- * // executed for all envs347- * });348- *349- * app.configure('stage', function(){350- * // executed staging env351- * });352- *353- * app.configure('stage', 'production', function(){354- * // executed for stage and production355- * });356- *357- * Note:358- *359- * These callbacks are invoked immediately, and360- * are effectively sugar for the following:361- *362- * var env = process.env.NODE_ENV || 'development';363- *364- * switch (env) {365- * case 'development':366- * ...367- * break;368- * case 'stage':369- * ...370- * break;371- * case 'production':372- * ...373- * break;374- * }375- *376- * @param {String} env...377- * @param {Function} fn378- * @return {app} for chaining379- * @api public380- */381-382-app.configure = function(env, fn){383- var envs = 'all'384- , args = [].slice.call(arguments);385- fn = args.pop();386- if (args.length) envs = args;387- if ('all' == envs || ~envs.indexOf(this.settings.env)) fn.call(this);388- return this;389-};390-391-/**338 * Delegate `.VERB(...)` calls to `router.VERB(...)`.339 */340 341 methods.forEach(function(method){135 unmodified linesdeleted:test/config.env.js-96 removed
1-2-var express = require('../');3-4-describe('config', function(){5- describe('.configure()', function(){6- describe('when no env is given', function(){7- it('should always execute', function(){8- var app = express();9- var calls = [];10-11- app.configure(function(){12- calls.push('all');13- });14-15- app.configure('test', function(){16- calls.push('test');17- });18-19- app.configure('test', function(){20- calls.push('test 2');21- });22-23- calls.should.eql(['all', 'test', 'test 2'])24- })25- })26-27- describe('when an env is given', function(){28- it('should only execute the matching env', function(){29- var app = express();30- var calls = [];31-32- app.set('env', 'development');33-34- app.configure('development', function(){35- calls.push('dev');36- });37-38- app.configure('test', function(){39- calls.push('test');40- });41-42- calls.should.eql(['dev']);43- })44- })45- 46- describe('when several envs are given', function(){47- it('should execute when matching one', function(){48- var app = express();49- var calls = [];50-51- app.set('env', 'development');52-53- app.configure('development', function(){54- calls.push('dev');55- });56-57- app.configure('test', 'development', function(){58- calls.push('dev 2');59- });60- 61- app.configure('development', 'test', function(){62- calls.push('dev 3');63- });64- 65- app.configure('test', function(){66- calls.push('dev 3');67- });68-69- calls.should.eql(['dev', 'dev 2', 'dev 3']);70- })71- })72-73- it('should execute in order as defined', function(){74- var app = express();75- var calls = [];76-77- app.configure(function(){78- calls.push('all');79- });80- 81- app.configure('test', function(){82- calls.push('test');83- });84-85- app.configure(function(){86- calls.push('all 2');87- });88-89- app.configure('test', function(){90- calls.push('test 2');91- });92-93- calls.should.eql(['all', 'test', 'all 2', 'test 2'])94- })95- })96-})