Skip to content

Commit

Permalink
fix(preprocessor): resolve relative patterns to basePath
Browse files Browse the repository at this point in the history
Merged from master to stable.

Closes #382

Conflicts:
	lib/config.js
	test/unit/config.spec.coffee
  • Loading branch information
vojtajina committed Mar 29, 2013
1 parent 612486e commit a4c7d19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ var normalizeConfig = function(config) {
log.warn('"reporter" is deprecated, use "reporters" instead');
}

// normalize preprocessors
var preprocessors = config.preprocessors || {};
var normalizedPreprocessors = config.preprocessors = Object.create(null);

Object.keys(preprocessors).forEach(function(pattern) {
var normalizedPattern = helper.normalizeWinPath(basePathResolve(pattern));

normalizedPreprocessors[normalizedPattern] = preprocessors[pattern];
});

return config;
};

Expand Down
12 changes: 12 additions & 0 deletions test/unit/config.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@ describe 'config', ->
expect(file.watched).to.equal true


it 'should resolve relative preprocessor patterns', ->
config = normalizeConfigWithDefaults
basePath: '/some/base'
preprocessors:
'*.coffee': 'coffee'
'/**/*.html': 'html2js'

expect(config.preprocessors).to.have.property '/some/base/*.coffee'
expect(config.preprocessors).not.to.have.property '*.coffee'
expect(config.preprocessors).to.have.property '/**/*.html'


describe 'createPatternObject', ->

it 'should parse string and set defaults', ->
Expand Down

0 comments on commit a4c7d19

Please sign in to comment.