command.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 = "run <script>";
  7. exports.describe = "Run an npm script in each package that contains that script";
  8. exports.builder = (yargs) => {
  9. yargs
  10. .example("$0 run build -- --silent", "# `npm run build --silent` in all packages with a build script")
  11. .parserConfiguration({
  12. "populate--": true,
  13. })
  14. .positional("script", {
  15. describe: "The npm script to run. Pass flags to send to the npm client after --",
  16. type: "string",
  17. })
  18. .options({
  19. "npm-client": {
  20. group: "Command Options:",
  21. describe: "Executable used to run scripts (npm, yarn, pnpm, ...).",
  22. defaultDescription: "npm",
  23. type: "string",
  24. requiresArg: true,
  25. },
  26. stream: {
  27. group: "Command Options:",
  28. describe: "Stream output with lines prefixed by package.",
  29. type: "boolean",
  30. },
  31. parallel: {
  32. group: "Command Options:",
  33. describe: "Run script with unlimited concurrency, streaming prefixed output.",
  34. type: "boolean",
  35. },
  36. "no-bail": {
  37. group: "Command Options:",
  38. describe: "Continue running script despite non-zero exit in a given package.",
  39. type: "boolean",
  40. },
  41. bail: {
  42. // proxy for --no-bail
  43. hidden: true,
  44. type: "boolean",
  45. },
  46. // This option controls prefix for stream output so that it can be disabled to be friendly
  47. // to tools like Visual Studio Code to highlight the raw results
  48. "no-prefix": {
  49. group: "Command Options:",
  50. describe: "Do not prefix streaming output.",
  51. type: "boolean",
  52. },
  53. prefix: {
  54. // proxy for --no-prefix
  55. hidden: true,
  56. type: "boolean",
  57. },
  58. profile: {
  59. group: "Command Options:",
  60. describe: "Profile script executions and output performance profile to default location.",
  61. type: "boolean",
  62. },
  63. "profile-location": {
  64. group: "Command Options:",
  65. describe: "Output performance profile to custom location instead of default project root.",
  66. type: "string",
  67. },
  68. });
  69. return filterOptions(yargs);
  70. };
  71. exports.handler = function handler(argv) {
  72. return require(".")(argv);
  73. };