rename-src-to-dest.js 654 B

12345678910111213141516171819
  1. var rename = require('gulp-rename');
  2. var config = require('../config');
  3. var normalizePath = require('../lib/normalize-path');
  4. /**
  5. * Returns a configured gulp-rename to pipe from asset sources to dest.
  6. * Usage: .pipe(renameSrcToDest())
  7. */
  8. var renameSrcToDest = function(log) {
  9. return rename(function(filePath) {
  10. if (log) console.log(filePath.dirname + '/' + filePath.basename + filePath.extname);
  11. filePath.dirname = normalizePath(filePath.dirname).replace(
  12. '/' + config.srcDir + '/',
  13. '/' + config.destDir + '/');
  14. if (log) console.log(filePath.dirname);
  15. });
  16. };
  17. module.exports = renameSrcToDest;