0

I'm using Jenkins pipeline to compile npm app. I want to use a parameter for my npm app, see each branch will publish the app under different name. Also, I need some "default value, for the developers when they are working in their local env

for example, my package.json:

{
"name": ${some_env_var} : default_value",
"version: 1.0.0
...
}

does it possible?

yiaca
  • 147
  • 2
  • 17
  • Can you provide more information about what you are trying to do? this will show how to pass a command line argument to a node program: https://stackoverflow.com/questions/4351521/how-do-i-pass-command-line-arguments-to-a-node-js-program – haydnD Mar 15 '21 at 13:23
  • Only the [`scripts`](https://docs.npmjs.com/cli/v6/using-npm/scripts) property of _package.json_ can include conditional logic - certainly _not_ the `name` property. To dynamically add the value for the `name` property consider pre-processing _package.json_ (i.e. parse and edit the JSON) via a custom _node.js_ script and then save a new _package.json_ to disk. – RobC Mar 15 '21 at 17:01
  • Yes I did that (via sed). I thought maybe there is a better way, Thanks – yiaca Mar 15 '21 at 17:14

0 Answers0