Reputation: 39018
This is step 1 in creating versioned folders for my deployment builds.
How would it be possible to pass in a string into the gulp.task below?
gulp.task('build', function(cb) {
runSequence('html-templates',
'stx-css',
'app-css',
'stx-js',
'app-js',
'build:copy',
'build:remove',
'build:index', cb);
});
I'd like to do something like this: gulp build 1.0.1
which will then pass the string 1.0.1
into the Gulpfile.
gulp.task('build', function(version, cb) {
console.log('version = ', version);
runSequence('html-templates',
'stx-css',
'app-css',
'stx-js',
'app-js',
'build:copy',
'build:remove',
'build:index', cb);
});
Upvotes: 0
Views: 282
Reputation: 39018
This can be accomplished using the env
variable!
Great video on the subject: https://www.youtube.com/watch?v=gRzCAyNrPV8
So I added this to my Gulpfile:
var env = process.env.V; // V={version number}
And then added a version task, which calls a function to print out a string that I pass in before calling my build task:
gulp.task('build', function(cb) {
runSequence('version',
'html-templates',
'stx-css',
'app-css',
'stx-js',
'app-js',
'build:copy',
'build:remove',
'build:index', cb);
});
gulp.task('version', function() {
return printOut(env);
});
function printOut(version) {
console.log('version = ',version);
}
Upvotes: 1