Merge pull request #139 from timhall/file-expand

Update file expand behavior
This commit is contained in:
Vlad Filippov 2014-06-07 15:08:47 -07:00
commit c040bc834c
4 changed files with 15 additions and 5 deletions

View File

@ -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, '/');
}); });

View File

@ -0,0 +1,2 @@
// Should be excluded with file expand
exclude = true;

View File

@ -0,0 +1,2 @@
// Should be include with file expand
include = true;

View File

@ -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();
} }
}; };