0

My first day with makefile and gulp and here i need to pass couple of parameters in my make command from the terminal and use those params later on elsewhere.

Presently my make command would be "make xyz". Need it to be something like "make xyz --paramOne=abc" and use this "abc" elsewhere in the framework.

Completely at loss here! I have been using grunt and aware of how grunt works. Any help or leads would be of immense help.

Thanks!

KBM
  • 341
  • 4
  • 16
  • possible duplicate of [Passing additional variables from command line to make](http://stackoverflow.com/questions/2826029/passing-additional-variables-from-command-line-to-make) – Amadan Sep 24 '15 at 06:49
  • @Amadan yes i went through this but could not figure out how to access the parameter passed , later on! If there are any globals which i can use or access to retrieve the parameters that were passed! – KBM Sep 24 '15 at 06:55
  • If you did `make xyz paramOne=abc`, you can access it in the Makefile as `$(paramOne)`. What do you mean, globals? – Amadan Sep 24 '15 at 06:58
  • What i meant was that i want to access it from another file in the framework. Say in testOne.js file, which is part of the framework, i want to use a switch condition using the parameter that was passed with the make command. – KBM Sep 24 '15 at 07:03
  • Is `testOne.js` run from `make`? Or do you want `make` to write a configuration file that `testOne.js` could read in the future? You need to explain much better what exactly you are asking. – Amadan Sep 24 '15 at 07:06
  • My apologies for the confusion. As i said it is my very first day with makefile and gulp . The make command starts the webdriverIO test suites . What i am trying to achieve here is that , i want to pass user privileges in as parameters while starting the scripts from terminal , using the make command, so that in my test scripts i can use that param and do some validations based on the parameter value. – KBM Sep 24 '15 at 07:18

1 Answers1

1

Use environment variables.

paramOne=abc make xyz

You can access the inherited environment variables in your code. For example, in Node.js,

console.log(process.env.paramOne);
// => abc
Amadan
  • 191,408
  • 23
  • 240
  • 301