I have a gulp task configured like so:
gulp.task('concatenate_client_js', function(){
return merge2(
gulp.src('./gulp/buildConfig.json')
.pipe(plugins.ngConfig('app.envConfig', {
environment: 'development'
})
),
gulp.src(paths.clientJS)
)
.pipe(plugins.concat('angular_app.js'))
.pipe(gulp.dest(paths.distScripts));
});
This task is then called in the runSequence of other tasks (split across different gulp files) I have like so:
gulp.task('prepare-dev-files', function(callback){
runSequence('clean_dist_dir', 'copy_assets', 'copy_serverFiles', 'copy_bower_css',
['compile_bower_sass', 'concatonate_bower_js'],
'compile_sass', 'concatenate_client_js', 'compile_main_js', callback);
});
gulp.task('prepare-staging-files', ['prepare-dev-files'], function(callback) {
runSequence('clean_test_src', 'copy_unitTestFiles', 'copy_files_for_coverage_report', 'karma_tests_ci', callback)
});
What I would like to be able to do is to set the environment
config option to the ngConfig
plugin in the concatenate_client_js
task based on args or params supplied to the task.
I have seen tools like yargs but am unsure how to use in my case. I would like to be able to supply an arg e.g --mode development
to the call to my task in the runSequence's, e.g.
gulp.task('prepare-staging-files', ['prepare-dev-files --mode staging'], function(callback) {
runSequence('clean_test_src', 'copy_unitTestFiles', 'copy_files_for_coverage_report', 'karma_tests_ci', callback)
});
And then add some switch code based on the mode argument passed to the task.
Is this achievable? Thanks