110.index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. exports.id = 110;
  3. exports.ids = [110];
  4. exports.modules = {
  5. /***/ 73608:
  6. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7. Object.defineProperty(exports, "__esModule", ({ value: true }));
  8. const snyk = __webpack_require__(9146);
  9. const validMethods = ['set', 'get', 'unset', 'clear'];
  10. async function config(method, ...args) {
  11. if (method && !validMethods.includes(method)) {
  12. throw new Error(`Unknown config command "${method}"`);
  13. }
  14. const key = args[0];
  15. if (method === 'set') {
  16. let res = '';
  17. args.forEach((item) => {
  18. const [key, val] = item.split(/=(.+)/);
  19. snyk.config.set(key, val);
  20. res += key + ' updated\n';
  21. // ensure we update the live library
  22. if (key === 'api') {
  23. snyk.api = val;
  24. }
  25. });
  26. return res;
  27. }
  28. if (method === 'get') {
  29. if (!key) {
  30. throw new Error('config:get requires an argument');
  31. }
  32. return snyk.config.get(key) || '';
  33. }
  34. if (method === 'unset') {
  35. if (!key) {
  36. throw new Error('config:unset requires an argument');
  37. }
  38. snyk.config.delete(key);
  39. if (key === 'api') {
  40. // ensure we update the live library
  41. snyk.api = null;
  42. }
  43. return `${key} deleted`;
  44. }
  45. if (method === 'clear') {
  46. snyk.config.clear();
  47. // ensure we update the live library
  48. snyk.api = null;
  49. return 'config cleared';
  50. }
  51. return Object.keys(snyk.config.all)
  52. .sort((a, b) => Number(a.toLowerCase() < b.toLowerCase()))
  53. .map((configKey) => `${configKey}: ${snyk.config.all[configKey]}`)
  54. .join('\n')
  55. .trim();
  56. }
  57. exports.default = config;
  58. /***/ })
  59. };
  60. ;
  61. //# sourceMappingURL=110.index.js.map