Hi there I am trying to use gulp 4.0 new feature gulp series. I have gulp functions I am trying to run in a series I also want to be able to call them individually. Both the coffee and vendor task call from a function which returns a promise.
The issue is it is not running a series it is executing coffee the vendor but also calling the allJs task which is the parrent
##
# Return gulp destinations depending on params
# FUTURE: This function will be resposible for
# exectuing the transaltion scripts
# @param {String} String representation of array of langs if anys
# @return {promise} Reutrns a promise with a arrray
# of destionations
##
getDest = (langs, path) ->
return new Promise (resolve, reject) ->
#Return default path if no lang specified or reject if no data
resolve [gulp.dest(buildDir+path)] if !langs
reject Error 'Empty language param' if typeof langs is Boolean
str = langs.split(",")
rtn = [] #Return array of destintion for each lang
rtn.push gulp.dest("public/" + o + path) for o in str
resolve rtn
##
# Complie Vendor javascript files
# @param {String} none
# @return {Stream} stream
##
gulp.task 'coffee', (done) ->
getDest(argv.lang, '/assets/js').then (response) ->
gulp.src([coffeeSrc],{ base: 'assets' })
.pipe(logger(
before: 'Compiling CoffeeScript files ...'
after: 'CoffeeScript files compiled successfully'
showChange: silent))
.pipe(coffee({bare: true}))
.on('error', gutil.log)
.on('error', gutil.beep)
.pipe(uglify())
.pipe(concat('app.min.js'))
.pipe(multistream.apply(undefined, response))
done()
.catch (error) ->
console.error 'failed', error
done(err)
##
# Complie Vendor javascript files
# @param {String} none
# @return {Stream} stream
##
gulp.task 'vendor', (done) ->
stream = getDest(argv.lang, '/assets/js').then (response) ->
gulp.src(["./assets/jsv2/vendor/jquery.min.js",vendorSrc])
.pipe(logger(
before: 'Compiling vendor javascript files ...'
after: 'Vendor javascript files compiled successfully'
showChange: silent))
.pipe(uglify())
.pipe(concat('vendor.min.js'))
.pipe(multistream.apply(undefined, response))
done()
.catch (error) ->
console.error 'failed', error
##
# Bundle all javascript files
# @param {String} none
# @return {Boolean} Finished
##
gulp.task 'allJs', gulp.series 'coffee', 'vendor', (done) ->
getDest(argv.lang, '/assets/js').then (response) ->
gulp.src(["./assets/jsv2/vendor/jquery.min.js",
buildDir + '/**/**/vendor.min.js',
buildDir + '/**/**/app.min.js'],{ base: 'assets' })
.pipe(logger(
before: 'Bundling javascript files ...'
after: 'Bundled javascript files compiled successfully'
showChange: silent))
.pipe(uglify())
.pipe(concat('all.min.js'))
.pipe(multistream.apply(undefined, response))
done()
.catch (error) ->
console.error 'failed', error
done()
Im pretty new to promises and gulp. I just got Visual studio code which is great I was trying to use the debugger but just couldn't figure it, im still a pretty amateur debugger.
via Alex Kirwan
No comments:
Post a Comment