Execute gulp task only if flag is passed? -
current code:
var open = require('open'); var gulp = require("gulp"); var pkg = require("../../package.json"); //opens launchpage default browser gulp.task("open", function () { open('http://localhost:' + pkg.webserverport + '/commonclient/launchpage.html'); });
right now, running gulp
command starts server , bunch of other compilation tasks. how modify run "open" task if type in gulp -o
or in command line?
you can inspecting process.argv
, or looking env flag on process.env
gulp.task("open", function () { if (process.argv.indexof('-o') > -1) { open('http://localhost:' + pkg.webserverport + '/commonclient/launchpage.html'); } });
or env variable
gulp.task("open", function () { if (processs.env.use_open) { open('http://localhost:' + pkg.webserverport + '/commonclient/launchpage.html'); } });
Comments
Post a Comment