Good afternoon, how can I pass the Angular-2 parameter to the script using Gulp? That in Angular-2 it was possible to receive value of this variable at start. To start gulp like this:

gulp start --type=dev 

And so that in Angulyar-2 it was possible to get the value of the type variable.

    1 answer 1

    You can connect the module yargs

     var argv = require('yargs').argv; 

    and do whatever you want with the values, for example, write to a file:

     var fs = require('fs'); fs.writeFile("my_script.ts", "export class MyType {\n" + " public gulpType: string = '" + argv.type + "';\n" + "}\n" fsErr); 

    and the file is already imported where necessary ...

    • yes, thank you, and I did it, even without yargs just through the process env - Denis Adamenko