Codebase list node-grunt-contrib-copy / c22e722
Fix for expand-less copies with multiple files Introduces a new test that uses a cwd- and expand-less target with multiple input files being copied to a single destination directory. In the task itself, the loop that operates on the list of `src` paths no longer persists the `dest` from loop-to-loop, allowing the `src` filename to actually show up in the full `dest` for successive files. Fixes #220. Partially reverts a15feecc7763269e995235dcb4647b223d67f516. Dave Shifflett 9 years ago
5 changed file(s) with 23 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
4343 {expand: true, cwd: 'test/fixtures', src: ['*.js'], dest: 'tmp/copy_test_files/'},
4444 {expand: true, cwd: 'test/fixtures', src: ['**', '!*.wav'], dest: 'tmp/copy_test_mix/'},
4545 {expand: true, cwd: 'test/fixtures', src: ['<%= test_vars.match %>'], dest: 'tmp/copy_test_v<%= test_vars.version %>/'}
46 ]
47 },
48
49 noexpandWild: {
50 files: [
51 {src: 'test/fixtures/*.js', dest: 'tmp/copy_test_noexpandWild/'}
4652 ]
4753 },
4854
4040 };
4141
4242 this.files.forEach(function(filePair) {
43 var dest = filePair.dest;
4443 isExpandedPair = filePair.orig.expand || false;
4544
4645 filePair.src.forEach(function(src) {
4746 src = unixifyPath(src);
48 dest = unixifyPath(dest);
47 var dest = unixifyPath(filePair.dest);
4948
5049 if (detectDestType(dest) === 'directory') {
5150 dest = (isExpandedPair) ? dest : path.join(dest, src);
1717 actual = fs.readdirSync('tmp/copy_test_v0.1.0').sort();
1818 expected = fs.readdirSync('test/expected/copy_test_v0.1.0').sort();
1919 test.deepEqual(expected, actual, 'should parse both dest and src templates');
20
21 test.done();
22 },
23
24 noexpandWild: function(test) {
25 'use strict';
26
27 test.expect(3);
28
29 ['/', '/test/', '/test/fixtures/'].forEach(function(subpath, i) {
30 var actual = fs.readdirSync('tmp/copy_test_noexpandWild' + subpath).sort();
31 var expected = fs.readdirSync('test/expected/copy_test_noexpandWild' + subpath).sort();
32 test.deepEqual(expected, actual, 'should copy file structure at level ' + i);
33 });
2034
2135 test.done();
2236 },