command.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. const { filterOptions } = require("@lerna/filter-options");
  3. /**
  4. * @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module
  5. */
  6. exports.command = "exec [cmd] [args..]";
  7. exports.describe = "Execute an arbitrary command in each package";
  8. exports.builder = (yargs) => {
  9. yargs
  10. .example("$0 exec ls -- --la", "# execute `ls -la` in all packages")
  11. .example("$0 exec -- ls --la", "# execute `ls -la` in all packages, keeping cmd outside")
  12. .parserConfiguration({
  13. "populate--": true,
  14. })
  15. .positional("cmd", {
  16. describe: "The command to execute. Any command flags must be passed after --",
  17. type: "string",
  18. })
  19. .positional("args", {
  20. describe: "Positional arguments (not recognized by lerna) to send to command",
  21. type: "string",
  22. })
  23. .options({
  24. stream: {
  25. group: "Command Options:",
  26. describe: "Stream output with lines prefixed by originating package name.",
  27. type: "boolean",
  28. },
  29. parallel: {
  30. group: "Command Options:",
  31. describe: "Execute command with unlimited concurrency, streaming prefixed output.",
  32. type: "boolean",
  33. },
  34. "no-bail": {
  35. group: "Command Options:",
  36. describe: "Continue executing command despite non-zero exit in a given package.",
  37. type: "boolean",
  38. },
  39. bail: {
  40. // proxy for --no-bail
  41. hidden: true,
  42. type: "boolean",
  43. },
  44. // This option controls prefix for stream output so that it can be disabled to be friendly
  45. // to tools like Visual Studio Code to highlight the raw results
  46. "no-prefix": {
  47. group: "Command Options:",
  48. describe: "Do not prefix streaming output.",
  49. type: "boolean",
  50. },
  51. prefix: {
  52. // proxy for --no-prefix
  53. hidden: true,
  54. type: "boolean",
  55. },
  56. profile: {
  57. group: "Command Options:",
  58. describe: "Profile command executions and output performance profile to default location.",
  59. type: "boolean",
  60. },
  61. "profile-location": {
  62. group: "Command Options:",
  63. describe: "Output performance profile to custom location instead of default project root.",
  64. type: "string",
  65. },
  66. });
  67. return filterOptions(yargs);
  68. };
  69. exports.handler = function handler(argv) {
  70. return require(".")(argv);
  71. };