Created
February 13, 2014 04:23
-
-
Save dwelch2344/8969706 to your computer and use it in GitHub Desktop.
A simple GulpJS plugin for copying resources into a specific folder (and not retaining their previous path)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var through = require('through'); | |
var File = require('gulp-util').File; | |
module.exports = function(){ | |
var files = []; | |
function onStream(file){ | |
files.push(file); | |
} | |
function onEnd(){ | |
for(var f in files){ | |
var file = files[f] | |
, split = file.path.split("/") | |
, name = split[split.length-1] | |
, joinedFile = new File({ | |
path: name, | |
contents: new Buffer(file.contents) | |
}) | |
; | |
this.emit('data', joinedFile); | |
} | |
this.emit('end'); | |
} | |
return through(onStream, onEnd); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flatCopy = require('./gulp-flat-copy'); | |
// ... | |
gulp.task('copy', function(){ | |
// ... | |
gulp.src(['**/*.js.map']) | |
.pipe(flatCopy()) | |
.pipe(gulp.dest('public/scripts')); | |
// ... | |
}); | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment