Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created December 3, 2019 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/88c71d61d14f4bad39a4c8f2f945e08e to your computer and use it in GitHub Desktop.
Save yairEO/88c71d61d14f4bad39a4c8f2f945e08e to your computer and use it in GitHub Desktop.
Get gulp env variable
var opts = process.argv.reduce((result, item) => {
if( item.indexOf('--') == 0 )
result[item.replace('--','')] = 1
return result;
}, {})
@yairEO
Copy link
Author

yairEO commented Dec 3, 2019

Credit - https://stackoverflow.com/a/32937333/104380

Calling a task with variables:

gulp myTask --envDev --skipTest

Using variables in a task:

gulp.task('build', () => {
    return gulp.src('src/tagify.js')
        .pipe( gulp.dest('./dist/') )
        .pipe(opts.envDev ? tap(noop) : uglify())
        .pipe( gulp.dest('./dist/') )
});

tap is a plugin that returns empty stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment