5
I work with a simple task of Gulp
, created to realize a deploy in a 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'));
});
that I spin with the with
$ gulp deploy-prod
There is another environment (of homologation) that obviously has different address and credentials. For this, I have a task calling for 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 by presenting slightly different characteristics at times of development.
My question is: is there a way to parameterize the execution of these tasks, via command line? My intention was to run
$ gulp deploy --prod
or
$ gulp deploy --homolog
and have only one task deploy
, that would perform a routine based on this flag. Is that possible? If so, how?
Good answer! The use of another module does not please me much, but it solves the problem. Let’s see if anyone else appears with a different answer. For the time being, +1
– Caio Felipe Pereira
I understand your implication with the use of various modules/dependencies, I added a second example to my previous answer, I hope to have helped, hugs.
– Rafael Berro
Perfect, there you go.
– Caio Felipe Pereira