Work with a simple task of Gulp
, created to perform a deploy in the production environment. In a simplified way, the task is:
gulp.task('deploy-prod', function () {
return gulp.src('dist/**')
.pipe(sftp({
host: '000.000.000.000',
user: 'user',
pass: 'pass',
remotePath: '/var/www/html/meusite/',
port: 22
}))
.pipe(gulp.dest('dist'));
});
I swipe with com
$ gulp deploy-prod
There is another environment (of homologation) that obviously has different addresses and credentials. For this, I have a task named deploy-homolog
, whose logic is the same. This is just one case, among many others, where I end up having to repeat the code of my tasks because they present slightly different characteristics at the moment of development.
My question is: is there a way to parameterize the execution of these tasks via the command line? My intention was to roll
$ gulp deploy --prod
or
$ gulp deploy --homolog
and have only one task deploy
, which would execute a routine based on this flag. It is possible? If so, how?