pretty.js 950 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.prettifyTargets = prettifyTargets;
  6. exports.prettifyVersion = prettifyVersion;
  7. var _semver = require("semver");
  8. var _targets = require("./targets");
  9. function prettifyVersion(version) {
  10. if (typeof version !== "string") {
  11. return version;
  12. }
  13. const {
  14. major,
  15. minor,
  16. patch
  17. } = _semver.parse(version);
  18. const parts = [major];
  19. if (minor || patch) {
  20. parts.push(minor);
  21. }
  22. if (patch) {
  23. parts.push(patch);
  24. }
  25. return parts.join(".");
  26. }
  27. function prettifyTargets(targets) {
  28. return Object.keys(targets).reduce((results, target) => {
  29. let value = targets[target];
  30. const unreleasedLabel = _targets.unreleasedLabels[target];
  31. if (typeof value === "string" && unreleasedLabel !== value) {
  32. value = prettifyVersion(value);
  33. }
  34. results[target] = value;
  35. return results;
  36. }, {});
  37. }
  38. //# sourceMappingURL=pretty.js.map