Skip to content

Commit

Permalink
task.normalizeMultiTaskFiles now flattens nested "files" arrays. Clos…
Browse files Browse the repository at this point in the history
…es gh-1034.
  • Loading branch information
JasonCust authored and cowboy committed Mar 7, 2014
1 parent 85ba05a commit ad963da
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/grunt/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ task.normalizeMultiTaskFiles = function(data, target) {
files.push({src: data.files[prop], dest: grunt.config.process(prop)});
}
} else if (Array.isArray(data.files)) {
data.files.forEach(function(obj) {
grunt.util._.flatten(data.files).forEach(function(obj) {
var prop;
if ('src' in obj || 'dest' in obj) {
files.push(obj);
Expand Down
105 changes: 105 additions & 0 deletions test/gruntfile/multi-task-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ module.exports = function(grunt) {
}
]
},
long4_mapping: {
options: {a: 8, c: 88},
files: [
'<%= run.long3_mapping.files %>'
]
},
long5_mapping: {
options: {a: 9, c: 99},
files: [
'<%= run.long3_mapping.files %>',
'<%= run.long4_mapping.files %>'
]
},
// Need to ensure the task function is run if no files or options were
// specified!
no_files_or_options: {},
Expand Down Expand Up @@ -294,6 +307,94 @@ module.exports = function(grunt) {
},
],
},
'run:long4_mapping': {
options: {a: 8, b: 11, c: 88, d: 9},
files: [
{
dest: 'foo/baz/file1.bar',
src: ['src/file1.js'],
extra: 123,
orig: {
expand: true,
cwd: grunt.config.get('mappings.cwd'),
src: ['*1.js', '*2.js'],
dest: grunt.config.get('mappings.dest'),
rename: grunt.config.get('mappings.rename'),
extra: 123,
},
},
{
dest: 'foo/baz/file2.bar',
src: ['src/file2.js'],
extra: 123,
orig: {
expand: true,
cwd: grunt.config.get('mappings.cwd'),
src: ['*1.js', '*2.js'],
dest: grunt.config.get('mappings.dest'),
rename: grunt.config.get('run.built_mapping.rename'),
extra: 123,
},
},
],
},
'run:long5_mapping': {
options: {a: 9, b: 11, c: 99, d: 9},
files: [
{
dest: 'foo/baz/file1.bar',
src: ['src/file1.js'],
extra: 123,
orig: {
expand: true,
cwd: grunt.config.get('mappings.cwd'),
src: ['*1.js', '*2.js'],
dest: grunt.config.get('mappings.dest'),
rename: grunt.config.get('mappings.rename'),
extra: 123,
},
},
{
dest: 'foo/baz/file2.bar',
src: ['src/file2.js'],
extra: 123,
orig: {
expand: true,
cwd: grunt.config.get('mappings.cwd'),
src: ['*1.js', '*2.js'],
dest: grunt.config.get('mappings.dest'),
rename: grunt.config.get('run.built_mapping.rename'),
extra: 123,
},
},
{
dest: 'foo/baz/file1.bar',
src: ['src/file1.js'],
extra: 123,
orig: {
expand: true,
cwd: grunt.config.get('mappings.cwd'),
src: ['*1.js', '*2.js'],
dest: grunt.config.get('mappings.dest'),
rename: grunt.config.get('mappings.rename'),
extra: 123,
},
},
{
dest: 'foo/baz/file2.bar',
src: ['src/file2.js'],
extra: 123,
orig: {
expand: true,
cwd: grunt.config.get('mappings.cwd'),
src: ['*1.js', '*2.js'],
dest: grunt.config.get('mappings.dest'),
rename: grunt.config.get('run.built_mapping.rename'),
extra: 123,
},
},
],
},
};

var assert = require('assert');
Expand Down Expand Up @@ -353,6 +454,10 @@ module.exports = function(grunt) {
'test:built_mapping',
'run:long3_mapping',
'test:long3_mapping',
'run:long4_mapping',
'test:long4_mapping',
'run:long5_mapping',
'test:long5_mapping',
'run',
'test:all',
'test:counters',
Expand Down

0 comments on commit ad963da

Please sign in to comment.