assertRequiredOptions.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = assertRequiredOptions;
  6. function _commander() {
  7. const data = require("commander");
  8. _commander = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _lodash() {
  14. const data = require("lodash");
  15. _lodash = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. /**
  21. * Copyright (c) Facebook, Inc. and its affiliates.
  22. *
  23. * This source code is licensed under the MIT license found in the
  24. * LICENSE file in the root directory of this source tree.
  25. *
  26. * @format
  27. */
  28. // Commander.js has a 2 years old open issue to support <...> syntax
  29. // for options. Until that gets merged, we run the checks manually
  30. // https://github.com/tj/commander.js/issues/230
  31. function assertRequiredOptions(options, passedOptions) {
  32. options.forEach(opt => {
  33. const option = new (_commander().Option)(opt.name);
  34. if (!option.required) {
  35. return;
  36. }
  37. const name = (0, _lodash().camelCase)(option.long);
  38. if (!passedOptions[name]) {
  39. // Provide commander.js like error message
  40. throw new Error(`Option "${option.long}" is missing`);
  41. }
  42. });
  43. }
  44. //# sourceMappingURL=assertRequiredOptions.js.map