Skip to content

Commit

Permalink
gulp-rename: update usage
Browse files Browse the repository at this point in the history
  • Loading branch information
enzy committed Dec 30, 2019
1 parent 0eaccea commit b93349b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
12 changes: 5 additions & 7 deletions lib/tasks/buildstamp.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

module.exports = function(gulp, config) {
module.exports = function (gulp, config) {

return function(done) {
if(!config.buildstamp || config.devmode) return done()
return function (done) {
if (!config.buildstamp || config.devmode) return done()
var c = require('better-console')
c.info('~ buildstamp')

Expand All @@ -21,10 +21,8 @@ module.exports = function(gulp, config) {
allowEmpty: true,
})

task = task.pipe(rename(function(oldPath) {
oldPath.basename = config.stamp + oldPath.basename

return oldPath
task = task.pipe(rename(function (filepath) {
filepath.basename = config.stamp + filepath.basename
}))

task = task.pipe(file('.buildstamp.txt', config.stamp + '\n'))
Expand Down
18 changes: 9 additions & 9 deletions lib/tasks/static.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = function(gulp, config) {
module.exports = function (gulp, config) {
var errorHandler = require('../helpers/error_handler')()

return function(done) {
if(!config.static) return done()
return function (done) {
if (!config.static) return done()
var c = require('better-console')
c.info('~ static')

Expand All @@ -13,21 +13,21 @@ module.exports = function(gulp, config) {
var task = gulp.src(config.static, { base: config.dir, cwd: config.dir, allowEmpty: true })

// Init plumber in devmode
if(config.devmode){
if (config.devmode) {
task = task.pipe(plumber({ errorHandler: errorHandler.fail }))
}

var path_src = path.normalize(config.src_folder)

task = task.pipe(rename(function(path) {
task = task.pipe(rename(function (filepath) {
// Extract src_folder from file paths
if(path.dirname.indexOf(path_src) === 0){
path.dirname = path.dirname.substr(path_src.length)
if (filepath.dirname.indexOf(path_src) === 0) {
filepath.dirname = filepath.dirname.substr(path_src.length)
}
}))

if(config.devmode){
task.on('end', function() {
if (config.devmode) {
task.on('end', function () {
errorHandler.done()
})
}
Expand Down

0 comments on commit b93349b

Please sign in to comment.