Surya
Surya

Reputation: 638

Passing a string as a parameter to a gulp task

  var gulp = require("grunt");

    gulp.task('taskName', function(strng) {
        console.log(strng);
    });

Generally, the gulp file is run as "gulp taskName" I want to know how to pass "strng" with the taskName in command line as a parameter

Upvotes: 1

Views: 1850

Answers (1)

Khaled Awad
Khaled Awad

Reputation: 1814

You may consider using yargs

reference: https://www.npmjs.com/package/yargs

In your gulpfile var args = require('yargs').argv;

In your command line $ gulp taskName --yourparamvariable=bar

To access the paramerter you've sent from your command line args.yourparamvariable

Upvotes: 3

Related Questions