Merge pull request #139 from timhall/file-expand
Update file expand behavior
This commit is contained in:
commit
c040bc834c
@ -117,13 +117,10 @@ exports.init = function(grunt, phantomjs) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.getRelativeFileList = function(outdir, patterns, options) {
|
exports.getRelativeFileList = function(outdir, patterns, options) {
|
||||||
var files = [];
|
|
||||||
patterns = patterns instanceof Array ? patterns : [ patterns ];
|
patterns = patterns instanceof Array ? patterns : [ patterns ];
|
||||||
options = options || {};
|
options = options || {};
|
||||||
patterns.forEach(function(listItem){
|
|
||||||
if (listItem) files = files.concat(grunt.file.expand(options, listItem));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
var files = grunt.file.expand(options, grunt.util._(patterns).compact());
|
||||||
files = grunt.util._(files).map(function(file){
|
files = grunt.util._(files).map(function(file){
|
||||||
return (/^https?:/).test(file) ? file : path.relative(outdir, file).replace(/\\/g, '/');
|
return (/^https?:/).test(file) ? file : path.relative(outdir, file).replace(/\\/g, '/');
|
||||||
});
|
});
|
||||||
|
2
test/fixtures/fileExpand/src/exclude.js
vendored
Normal file
2
test/fixtures/fileExpand/src/exclude.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Should be excluded with file expand
|
||||||
|
exclude = true;
|
2
test/fixtures/fileExpand/src/include.js
vendored
Normal file
2
test/fixtures/fileExpand/src/include.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Should be include with file expand
|
||||||
|
include = true;
|
@ -1,6 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var grunt = require('grunt');
|
var grunt = require('grunt'),
|
||||||
|
phantomjs = require('grunt-lib-phantomjs').init(grunt),
|
||||||
|
jasmine = require('../tasks/lib/jasmine.js').init(grunt, phantomjs);
|
||||||
|
|
||||||
// Majority of test benefit comes from running the task itself.
|
// Majority of test benefit comes from running the task itself.
|
||||||
|
|
||||||
@ -40,6 +42,13 @@ exports.jasmine = {
|
|||||||
|
|
||||||
test.equal(normalize(actual),normalize(expected), 'default test runner template');
|
test.equal(normalize(actual),normalize(expected), 'default test runner template');
|
||||||
|
|
||||||
|
test.done();
|
||||||
|
},
|
||||||
|
|
||||||
|
fileExpand: function(test) {
|
||||||
|
var patterns = ['test/fixtures/fileExpand/src/*.js', '!test/fixtures/fileExpand/src/exclude.js']
|
||||||
|
var expected = ['test/fixtures/fileExpand/src/include.js'];
|
||||||
|
test.deepEqual(jasmine.getRelativeFileList('', patterns, {}), expected, 'should properly expand file list')
|
||||||
test.done();
|
test.done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user