pretty.js 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 parts = [_semver.major(version)];
  14. const minor = _semver.minor(version);
  15. const patch = _semver.patch(version);
  16. if (minor || patch) {
  17. parts.push(minor);
  18. }
  19. if (patch) {
  20. parts.push(patch);
  21. }
  22. return parts.join(".");
  23. }
  24. function prettifyTargets(targets) {
  25. return Object.keys(targets).reduce((results, target) => {
  26. let value = targets[target];
  27. const unreleasedLabel = _targets.unreleasedLabels[target];
  28. if (typeof value === "string" && unreleasedLabel !== value) {
  29. value = prettifyVersion(value);
  30. }
  31. results[target] = value;
  32. return results;
  33. }, {});
  34. }