gulp-nube-pullout
Version:
change all files to root path or specify path
33 lines (26 loc) • 859 B
JavaScript
'use strict';
var gutil = require('gulp-util');
var PluginError = gutil.PluginError;
var through = require('through2');
var Path = require('path');
var hash = require('rev-hash');
var PLUGIN_NAME = 'gulp-nube-pullout';
/////////////////////////////////////
// Main Gulp Nube Pullout function //
/////////////////////////////////////
module.exports = function(options) {
var _base = (options && "base" in options) ? options.base : "";
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
return cb();
}
if (file.isStream()) {
return cb(new PluginError(file, "Streaming not supported"));
}
var paths = Path.parse(file.relative);
file.basename = paths.name + "-" + hash(new Buffer(file.relative)) + paths.ext;
file.pullPath = Path.resolve(file.base, file.basename);
file.path = file.pullPath;
cb(null, file);
});
};