0

I am trying to change the {variable} part in my custom-defined npm run deploy script

"scripts":{
      "deploy": "npm run build && scp -r ./public example@192.200.0.11:/home/{DIRECTORY}/index.js",
}

I want to run it like npm run deploy --DIRECTORY:project99

okatarismet
  • 276
  • 2
  • 5
  • This should help you https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script – andychukse May 17 '22 at 15:18

1 Answers1

0

You can pass arguments to npm run as Environment variable. See Npm Docs

 "scripts": {
    "deploy": "npm run build && scp -r ./public example@192.200.0.11:/home/${NPM_CONFIG_DIRECTORY}/index.js"
    },

This should work

npm run deploy --DIRECTORY=project99
andychukse
  • 520
  • 9
  • 19