Skip to content
Myr

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

2 files+0 added−150 removed

modified:lib/application.js-54 removed
333 unmodified lines
334 return this.set(setting, false);335};336337/**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 */381382app.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};390391/**338 * Delegate `.VERB(...)` calls to `router.VERB(...)`.339 */340341methods.forEach(function(method){
135 unmodified lines
deleted:test/config.env.js-96 removed
12var express = require('../');34describe('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 = [];1011 app.configure(function(){12 calls.push('all');13 });1415 app.configure('test', function(){16 calls.push('test');17 });1819 app.configure('test', function(){20 calls.push('test 2');21 });2223 calls.should.eql(['all', 'test', 'test 2'])24 })25 })2627 describe('when an env is given', function(){28 it('should only execute the matching env', function(){29 var app = express();30 var calls = [];3132 app.set('env', 'development');3334 app.configure('development', function(){35 calls.push('dev');36 });3738 app.configure('test', function(){39 calls.push('test');40 });4142 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 = [];5051 app.set('env', 'development');5253 app.configure('development', function(){54 calls.push('dev');55 });5657 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 });6869 calls.should.eql(['dev', 'dev 2', 'dev 3']);70 })71 })7273 it('should execute in order as defined', function(){74 var app = express();75 var calls = [];7677 app.configure(function(){78 calls.push('all');79 });80 81 app.configure('test', function(){82 calls.push('test');83 });8485 app.configure(function(){86 calls.push('all 2');87 });8889 app.configure('test', function(){90 calls.push('test 2');91 });9293 calls.should.eql(['all', 'test', 'all 2', 'test 2'])94 })95 })96})