From fb841a799d83209a6e0d58722cf6239e4990b946 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 16 Jul 2015 20:50:42 +0200 Subject: [PATCH] fix(file-list): Normalize glob patterns 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 --- lib/file-list.js | 3 ++- test/unit/file-list.spec.coffee | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/file-list.js b/lib/file-list.js index 228e3d1a2..64e25b4c8 100644 --- a/lib/file-list.js +++ b/lib/file-list.js @@ -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') @@ -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()) diff --git a/test/unit/file-list.spec.coffee b/test/unit/file-list.spec.coffee index f4206d563..62073650f 100644 --- a/test/unit/file-list.spec.coffee +++ b/test/unit/file-list.spec.coffee @@ -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'),