From 4dde16087d0a704a47528d44e23ace0c536d8c72 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 12 Mar 2013 19:51:52 -0700 Subject: [PATCH] feat(config): normalize string preprocessors into an array To make it backwards compatible. --- lib/config.js | 7 +++++++ test/unit/config.spec.coffee | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/config.js b/lib/config.js index 4ef35a2b8..aaaf91078 100644 --- a/lib/config.js +++ b/lib/config.js @@ -104,6 +104,13 @@ var normalizeConfig = function(config) { log.warn('"reporter" is deprecated, use "reporters" instead'); } + var preprocessors = config.preprocessors || {}; + Object.keys(preprocessors).forEach(function(pattern) { + if (helper.isString(preprocessors[pattern])) { + preprocessors[pattern] = [preprocessors[pattern]]; + } + }); + return config; }; diff --git a/test/unit/config.spec.coffee b/test/unit/config.spec.coffee index 33f1c8727..c6b75b625 100644 --- a/test/unit/config.spec.coffee +++ b/test/unit/config.spec.coffee @@ -270,6 +270,16 @@ describe 'config', -> expect(file.watched).to.equal true + it 'should normalize preprocessors to an array', -> + config = normalizeConfigWithDefaults + preprocessors: + '**/*.coffee': 'coffee' + '**/*.html': 'html2js' + + expect(config.preprocessors['**/*.coffee']).to.deep.equal ['coffee'] + expect(config.preprocessors['**/*.html']).to.deep.equal ['html2js'] + + describe 'createPatternObject', -> it 'should parse string and set defaults', ->