Skip to content

Commit

Permalink
clean up code, support flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
vanetix committed Mar 8, 2013
1 parent d877c88 commit 7abaf3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -28,7 +28,8 @@ module.exports = function(grunt) {
basic: { basic: {
cwd: 'test/cases', cwd: 'test/cases',
assets: '../assets/*', assets: '../assets/*',
src: ['*'] src: ['*'],
dest: 'tmp'
} }
} }
}); });
Expand Down
13 changes: 7 additions & 6 deletions tasks/mapper.js
Expand Up @@ -33,7 +33,6 @@ module.exports = function(grunt) {
*/ */


assets = grunt.file.expand({cwd: cwd}, f.assets); assets = grunt.file.expand({cwd: cwd}, f.assets);
console.dir(assets);


/** /**
* Filter out non-existent files then iterate over all files * Filter out non-existent files then iterate over all files
Expand All @@ -55,20 +54,22 @@ module.exports = function(grunt) {
}); });


src.forEach(function(p) { src.forEach(function(p) {
var s = f.dest ? f.dest : p; var s;

p = f.flatten ? path.basename(p) : p;
s = f.dest ? path.join(f.dest, p) : p;


if(cwd) { if(cwd) {
p = path.join(cwd, p); p = path.join(cwd, p);
} }


grunt.log.oklns(map(p, assets));

/** /**
* If `f.dest` is set, save to `f.dest` otherwize * If `f.dest` is set, save to `f.dest` otherwise
* overwrite the original * overwrite the original
*/ */


//grunt.file.write(map(p, assets), s); grunt.log.writeln('✔ '.green + s.grey);
grunt.file.write(s, map(p, assets));
}); });


}); });
Expand Down

0 comments on commit 7abaf3e

Please sign in to comment.