简体   繁体   English

如何使用 NX CLI 将命令转发到运行命令?

[英]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)鉴于我在 angular.json 中有条目,这些条目使用无服务器 CLI 定义了各种命令(例如)

"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: EG是这样的:

"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')?然后用 nx run my-app:sls MYCOMMAND (EG 'deploy' 或 '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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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