broccoli-caching-writer
Advanced tools
Comparing version 2.3.1 to 3.0.0
## master | ||
## 3.0.0 | ||
* listFiles and listEntries output is now lexicographically sorted (by related path) | ||
## 2.3.1 | ||
@@ -4,0 +8,0 @@ |
15
index.js
@@ -218,3 +218,16 @@ 'use strict'; | ||
} | ||
return listEntries(this._lastKeys, []); | ||
return listEntries(this._lastKeys, []).sort(function (a, b) { | ||
var pathA = a.relativePath; | ||
var pathB = b.relativePath; | ||
if (pathA === pathB) { | ||
return 0; | ||
} else if (pathA < pathB) { | ||
return -1; | ||
} else { | ||
return 1; | ||
} | ||
} | ||
); | ||
}; | ||
@@ -221,0 +234,0 @@ |
{ | ||
"name": "broccoli-caching-writer", | ||
"version": "2.3.1", | ||
"version": "3.0.0", | ||
"description": "Broccoli plugin that allows simple caching (while still allowing N:N) based on the input tree hash.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -59,6 +59,6 @@ # Broccoli Caching Writer | ||
## `plugin.listFiles` | ||
list files matched, helpful as it allows us avoid a second glob | ||
list files matched, helpful as it allows us avoid a second glob, lexicographically sorted by relativePath. | ||
## `plugin.listEntries` | ||
list entries (stat objects) of files matched, helpful when further FS information is required on rebuild. | ||
list entries (stat objects) of files matched, helpful when further FS information is required on rebuild, lexicographically sorted by relativePath. | ||
@@ -65,0 +65,0 @@ ## ZOMG!!! TESTS?!?!!? |
@@ -285,11 +285,16 @@ 'use strict'; | ||
describe('listFiles', function() { | ||
var listFiles; | ||
function getListFilesFor(options, sourcePaths) { | ||
var listFiles; | ||
function getListFilesFor(options) { | ||
setupCachingWriter([sourcePath], options, function() { | ||
if (arguments.length < 2) { | ||
sourcePaths = [sourcePath]; | ||
} | ||
setupCachingWriter(sourcePaths, options, function() { | ||
var writer = this; | ||
listFiles = this.listFiles().map(function(p) { | ||
return path.relative(writer.inputPaths[0], p); | ||
listFiles = this.listFiles().map(function(fullPath) { | ||
return path.basename(fullPath); | ||
}); | ||
}); | ||
return expectRebuild().then(function() { | ||
@@ -322,12 +327,28 @@ return listFiles; | ||
}); | ||
it('returns a sorted array', function() { | ||
return expect(getListFilesFor( | ||
{}, [sourcePath, secondaryPath] | ||
)).to.eventually.deep.equal([ | ||
'bar.js', | ||
'core.js', | ||
'foo-baz.js', | ||
'foo.js', | ||
'main.js', | ||
]); | ||
}); | ||
}); | ||
describe('listEntries', function() { | ||
var listEntries; | ||
function getListEntriesFor(options, sourcePaths) { | ||
var listEntries; | ||
function getListEntriesFor(options) { | ||
setupCachingWriter([sourcePath], options, function() { | ||
if (arguments.length < 2) { | ||
sourcePaths = [sourcePath]; | ||
} | ||
setupCachingWriter(sourcePaths, options, function() { | ||
var writer = this; | ||
listEntries = this.listEntries().map(function(p) { | ||
return path.relative(writer.inputPaths[0], p.fullPath); | ||
listEntries = this.listEntries().map(function(entry) { | ||
return path.basename(entry.fullPath); | ||
}); | ||
@@ -363,2 +384,15 @@ }); | ||
}); | ||
it('returns a sorted array', function() { | ||
return expect(getListEntriesFor( | ||
{}, [sourcePath, secondaryPath] | ||
)).to.eventually.deep.equal([ | ||
'bar.js', | ||
'core.js', | ||
'foo-baz.js', | ||
'foo.js', | ||
'main.js', | ||
]); | ||
}); | ||
}); | ||
@@ -365,0 +399,0 @@ }); |
35417
694