简体   繁体   中英

How to forward command into run-commands using NX CLI?

Given I have entries in angular.json that define various commands using the serverless CLI (as an example)

"serverless-deploy": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "command": "npx serverless deploy",
    "cwd": "apps/my-app"
  }
},
"serverless-remove": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "command": "npx serverless remove",
    "cwd": "apps/my-app"
  }
}

How can I improve this by reducing duplication and combining it into one entry so that I can forward the command in?

EG something like this:

"sls": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "command": "npx serverless",
    "cwd": "apps/my-app"
  }
}

And then call it with nx run my-app:sls MYCOMMAND (EG 'deploy' or 'remove')? Unfortunately the above doesn't work but would love to know if this is possible.

"sls": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "commands": [
      "npx sls {args.cmd}"
    ],
    "cwd": "apps/api",
    "parallel": false
  }
},

nx run api:sls --cmd=deploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM