Skip to content

Commit

Permalink
feat(config): normalize string preprocessors into an array
Browse files Browse the repository at this point in the history
To make it backwards compatible.
  • Loading branch information
vojtajina committed Mar 13, 2013
1 parent 1d17c1a commit 4dde160
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
10 changes: 10 additions & 0 deletions test/unit/config.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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', ->
Expand Down

0 comments on commit 4dde160

Please sign in to comment.