Skip to content

Commit

Permalink
fix(file-list): Normalize glob patterns
Browse files Browse the repository at this point in the history
Normalize glob patterns before they are passed to
node-glob to avoid issues on windows, where the resolved
files and the statCache entries do not match.

Closes #1494
  • Loading branch information
dignifiedquire committed Jul 16, 2015
1 parent 09d64ed commit fb841a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Promise = require('bluebird')
var mm = require('minimatch')
var Glob = require('glob').Glob
var fs = Promise.promisifyAll(require('fs'))
var pathLib = require('path')

var File = require('./file')
var Url = require('./url')
Expand Down Expand Up @@ -155,7 +156,7 @@ List.prototype._refresh = function () {
return Promise.resolve()
}

var mg = new Glob(pattern, GLOB_OPTS)
var mg = new Glob(pathLib.normalize(pattern), GLOB_OPTS)
var files = mg.found
buckets.set(pattern, new Set())

Expand Down
18 changes: 18 additions & 0 deletions test/unit/file-list.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,24 @@ describe 'FileList', ->
expect(file1.mtime).to.be.eql mg.statCache['/some/a.js'].mtime
expect(file2.mtime).to.be.eql mg.statCache['/some/b.js'].mtime

it 'sets the mtime for relative patterns', ->
list = new List(
patterns('/some/world/../*.js', '*.txt'),
[],
emitter,
preprocess
)

list.refresh().then (files) ->
bucket = list.buckets.get('/some/world/../*.js')

file1 = findFile '/some/a.js', bucket
file2 = findFile '/some/b.js', bucket

expect(file1.mtime).to.be.eql mg.statCache['/some/a.js'].mtime
expect(file2.mtime).to.be.eql mg.statCache['/some/b.js'].mtime


it 'ingores excluded files', ->
list = new List(
patterns('*.txt'),
Expand Down

0 comments on commit fb841a7

Please sign in to comment.