keep-a-changelog 2.2.1 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +26 -2
  2. package/README.md +27 -8
  3. package/esm/_dnt.shims.js +0 -1
  4. package/esm/bin.js +8 -3
  5. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +3 -2
  6. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_util.d.ts +3 -0
  7. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +46 -0
  8. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/mod.d.ts +3 -1
  9. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +4 -1
  10. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/posix.d.ts +7 -5
  11. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +50 -108
  12. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/win32.d.ts +7 -5
  13. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +23 -82
  14. package/esm/deps/deno.land/std@0.203.0/semver/_shared.d.ts +42 -0
  15. package/esm/deps/deno.land/std@0.203.0/semver/_shared.js +230 -0
  16. package/esm/deps/deno.land/std@0.203.0/semver/cmp.d.ts +9 -0
  17. package/esm/deps/deno.land/std@0.203.0/semver/cmp.js +35 -0
  18. package/esm/deps/deno.land/std@0.203.0/semver/comparator_format.d.ts +8 -0
  19. package/esm/deps/deno.land/std@0.203.0/semver/comparator_format.js +11 -0
  20. package/esm/deps/deno.land/std@0.203.0/semver/comparator_intersects.d.ts +8 -0
  21. package/esm/deps/deno.land/std@0.203.0/semver/comparator_intersects.js +45 -0
  22. package/esm/deps/deno.land/std@0.203.0/semver/comparator_max.d.ts +9 -0
  23. package/esm/deps/deno.land/std@0.203.0/semver/comparator_max.js +45 -0
  24. package/esm/deps/deno.land/std@0.203.0/semver/comparator_min.d.ts +8 -0
  25. package/esm/deps/deno.land/std@0.203.0/semver/comparator_min.js +32 -0
  26. package/esm/deps/deno.land/std@0.203.0/semver/compare.d.ts +10 -0
  27. package/esm/deps/deno.land/std@0.203.0/semver/compare.js +18 -0
  28. package/esm/deps/deno.land/std@0.203.0/semver/compare_build.d.ts +13 -0
  29. package/esm/deps/deno.land/std@0.203.0/semver/compare_build.js +23 -0
  30. package/esm/deps/deno.land/std@0.203.0/semver/constants.d.ts +42 -0
  31. package/esm/deps/deno.land/std@0.203.0/semver/constants.js +75 -0
  32. package/esm/deps/deno.land/std@0.203.0/semver/difference.d.ts +4 -0
  33. package/esm/deps/deno.land/std@0.203.0/semver/difference.js +26 -0
  34. package/esm/deps/deno.land/std@0.203.0/semver/eq.d.ts +4 -0
  35. package/esm/deps/deno.land/std@0.203.0/semver/eq.js +7 -0
  36. package/esm/deps/deno.land/std@0.203.0/semver/format.d.ts +12 -0
  37. package/esm/deps/deno.land/std@0.203.0/semver/format.js +54 -0
  38. package/esm/deps/deno.land/std@0.203.0/semver/gt.d.ts +3 -0
  39. package/esm/deps/deno.land/std@0.203.0/semver/gt.js +5 -0
  40. package/esm/deps/deno.land/std@0.203.0/semver/gte.d.ts +3 -0
  41. package/esm/deps/deno.land/std@0.203.0/semver/gte.js +5 -0
  42. package/esm/deps/deno.land/std@0.203.0/semver/gtr.d.ts +3 -0
  43. package/esm/deps/deno.land/std@0.203.0/semver/gtr.js +5 -0
  44. package/esm/deps/deno.land/std@0.203.0/semver/increment.d.ts +28 -0
  45. package/esm/deps/deno.land/std@0.203.0/semver/increment.js +207 -0
  46. package/esm/deps/deno.land/std@0.203.0/semver/is_semver.d.ts +17 -0
  47. package/esm/deps/deno.land/std@0.203.0/semver/is_semver.js +41 -0
  48. package/esm/deps/deno.land/std@0.203.0/semver/is_semver_comparator.d.ts +12 -0
  49. package/esm/deps/deno.land/std@0.203.0/semver/is_semver_comparator.js +31 -0
  50. package/esm/deps/deno.land/std@0.203.0/semver/is_semver_range.d.ts +12 -0
  51. package/esm/deps/deno.land/std@0.203.0/semver/is_semver_range.js +22 -0
  52. package/esm/deps/deno.land/std@0.203.0/semver/lt.d.ts +3 -0
  53. package/esm/deps/deno.land/std@0.203.0/semver/lt.js +5 -0
  54. package/esm/deps/deno.land/std@0.203.0/semver/lte.d.ts +3 -0
  55. package/esm/deps/deno.land/std@0.203.0/semver/lte.js +5 -0
  56. package/esm/deps/deno.land/std@0.203.0/semver/ltr.d.ts +3 -0
  57. package/esm/deps/deno.land/std@0.203.0/semver/ltr.js +5 -0
  58. package/esm/deps/deno.land/std@0.203.0/semver/max_satisfying.d.ts +9 -0
  59. package/esm/deps/deno.land/std@0.203.0/semver/max_satisfying.js +14 -0
  60. package/esm/deps/deno.land/std@0.203.0/semver/min_satisfying.d.ts +9 -0
  61. package/esm/deps/deno.land/std@0.203.0/semver/min_satisfying.js +14 -0
  62. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.203.0}/semver/mod.d.ts +88 -176
  63. package/esm/deps/deno.land/std@0.203.0/semver/mod.js +313 -0
  64. package/esm/deps/deno.land/std@0.203.0/semver/neq.d.ts +3 -0
  65. package/esm/deps/deno.land/std@0.203.0/semver/neq.js +5 -0
  66. package/esm/deps/deno.land/std@0.203.0/semver/outside.d.ts +11 -0
  67. package/esm/deps/deno.land/std@0.203.0/semver/outside.js +67 -0
  68. package/esm/deps/deno.land/std@0.203.0/semver/parse.d.ts +8 -0
  69. package/esm/deps/deno.land/std@0.203.0/semver/parse.js +66 -0
  70. package/esm/deps/deno.land/std@0.203.0/semver/parse_comparator.d.ts +7 -0
  71. package/esm/deps/deno.land/std@0.203.0/semver/parse_comparator.js +28 -0
  72. package/esm/deps/deno.land/std@0.203.0/semver/parse_range.d.ts +7 -0
  73. package/esm/deps/deno.land/std@0.203.0/semver/parse_range.js +292 -0
  74. package/esm/deps/deno.land/std@0.203.0/semver/range_format.d.ts +8 -0
  75. package/esm/deps/deno.land/std@0.203.0/semver/range_format.js +11 -0
  76. package/esm/deps/deno.land/std@0.203.0/semver/range_intersects.d.ts +8 -0
  77. package/esm/deps/deno.land/std@0.203.0/semver/range_intersects.js +35 -0
  78. package/esm/deps/deno.land/std@0.203.0/semver/range_max.d.ts +7 -0
  79. package/esm/deps/deno.land/std@0.203.0/semver/range_max.js +15 -0
  80. package/esm/deps/deno.land/std@0.203.0/semver/range_min.d.ts +7 -0
  81. package/esm/deps/deno.land/std@0.203.0/semver/range_min.js +14 -0
  82. package/esm/deps/deno.land/std@0.203.0/semver/rcompare.d.ts +8 -0
  83. package/esm/deps/deno.land/std@0.203.0/semver/rcompare.js +10 -0
  84. package/esm/deps/deno.land/std@0.203.0/semver/rsort.d.ts +3 -0
  85. package/esm/deps/deno.land/std@0.203.0/semver/rsort.js +5 -0
  86. package/esm/deps/deno.land/std@0.203.0/semver/sort.d.ts +3 -0
  87. package/esm/deps/deno.land/std@0.203.0/semver/sort.js +5 -0
  88. package/esm/deps/deno.land/std@0.203.0/semver/test_comparator.d.ts +8 -0
  89. package/esm/deps/deno.land/std@0.203.0/semver/test_comparator.js +10 -0
  90. package/esm/deps/deno.land/std@0.203.0/semver/test_range.d.ts +8 -0
  91. package/esm/deps/deno.land/std@0.203.0/semver/test_range.js +16 -0
  92. package/esm/deps/deno.land/std@0.203.0/semver/types.d.ts +44 -0
  93. package/esm/deps/deno.land/std@0.203.0/semver/types.js +2 -0
  94. package/{types → esm}/src/Changelog.d.ts +4 -2
  95. package/esm/src/Changelog.js +25 -4
  96. package/{types → esm}/src/Release.d.ts +5 -4
  97. package/esm/src/Release.js +21 -22
  98. package/esm/src/deps.d.ts +2 -0
  99. package/esm/src/deps.js +1 -1
  100. package/esm/test/changelog.custom.type.md +2 -3
  101. package/esm/test/changelog.expected.linted.md +3 -4
  102. package/esm/test/changelog.expected.md +3 -4
  103. package/esm/test/changelog.md +3 -4
  104. package/esm/test/empty.expected.md +2 -2
  105. package/package.json +6 -13
  106. package/script/_dnt.polyfills.d.ts +11 -0
  107. package/script/_dnt.shims.d.ts +5 -0
  108. package/script/_dnt.shims.js +0 -1
  109. package/script/bin.d.ts +2 -0
  110. package/script/bin.js +8 -3
  111. package/script/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
  112. package/script/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
  113. package/script/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
  114. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +4 -3
  115. package/script/deps/deno.land/std@0.189.0/path/_constants.d.ts +39 -0
  116. package/script/deps/deno.land/std@0.189.0/path/_interface.d.ts +26 -0
  117. package/script/deps/deno.land/std@0.189.0/path/_util.d.ts +11 -0
  118. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +50 -1
  119. package/script/deps/deno.land/std@0.189.0/path/common.d.ts +13 -0
  120. package/script/deps/deno.land/std@0.189.0/path/glob.d.ts +83 -0
  121. package/script/deps/deno.land/std@0.189.0/path/mod.d.ts +11 -0
  122. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +5 -2
  123. package/script/deps/deno.land/std@0.189.0/path/posix.d.ts +86 -0
  124. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +48 -106
  125. package/script/deps/deno.land/std@0.189.0/path/separator.d.ts +2 -0
  126. package/script/deps/deno.land/std@0.189.0/path/win32.d.ts +91 -0
  127. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +22 -81
  128. package/script/deps/deno.land/std@0.203.0/semver/_shared.d.ts +42 -0
  129. package/script/deps/deno.land/std@0.203.0/semver/_shared.js +248 -0
  130. package/script/deps/deno.land/std@0.203.0/semver/cmp.d.ts +9 -0
  131. package/script/deps/deno.land/std@0.203.0/semver/cmp.js +39 -0
  132. package/script/deps/deno.land/std@0.203.0/semver/comparator_format.d.ts +8 -0
  133. package/script/deps/deno.land/std@0.203.0/semver/comparator_format.js +15 -0
  134. package/script/deps/deno.land/std@0.203.0/semver/comparator_intersects.d.ts +8 -0
  135. package/script/deps/deno.land/std@0.203.0/semver/comparator_intersects.js +49 -0
  136. package/script/deps/deno.land/std@0.203.0/semver/comparator_max.d.ts +9 -0
  137. package/script/deps/deno.land/std@0.203.0/semver/comparator_max.js +49 -0
  138. package/script/deps/deno.land/std@0.203.0/semver/comparator_min.d.ts +8 -0
  139. package/script/deps/deno.land/std@0.203.0/semver/comparator_min.js +36 -0
  140. package/script/deps/deno.land/std@0.203.0/semver/compare.d.ts +10 -0
  141. package/script/deps/deno.land/std@0.203.0/semver/compare.js +22 -0
  142. package/script/deps/deno.land/std@0.203.0/semver/compare_build.d.ts +13 -0
  143. package/script/deps/deno.land/std@0.203.0/semver/compare_build.js +27 -0
  144. package/script/deps/deno.land/std@0.203.0/semver/constants.d.ts +42 -0
  145. package/script/deps/deno.land/std@0.203.0/semver/constants.js +78 -0
  146. package/script/deps/deno.land/std@0.203.0/semver/difference.d.ts +4 -0
  147. package/script/deps/deno.land/std@0.203.0/semver/difference.js +30 -0
  148. package/script/deps/deno.land/std@0.203.0/semver/eq.d.ts +4 -0
  149. package/script/deps/deno.land/std@0.203.0/semver/eq.js +11 -0
  150. package/script/deps/deno.land/std@0.203.0/semver/format.d.ts +12 -0
  151. package/script/deps/deno.land/std@0.203.0/semver/format.js +58 -0
  152. package/script/deps/deno.land/std@0.203.0/semver/gt.d.ts +3 -0
  153. package/script/deps/deno.land/std@0.203.0/semver/gt.js +9 -0
  154. package/script/deps/deno.land/std@0.203.0/semver/gte.d.ts +3 -0
  155. package/script/deps/deno.land/std@0.203.0/semver/gte.js +9 -0
  156. package/script/deps/deno.land/std@0.203.0/semver/gtr.d.ts +3 -0
  157. package/script/deps/deno.land/std@0.203.0/semver/gtr.js +9 -0
  158. package/script/deps/deno.land/std@0.203.0/semver/increment.d.ts +28 -0
  159. package/script/deps/deno.land/std@0.203.0/semver/increment.js +211 -0
  160. package/script/deps/deno.land/std@0.203.0/semver/is_semver.d.ts +17 -0
  161. package/script/deps/deno.land/std@0.203.0/semver/is_semver.js +45 -0
  162. package/script/deps/deno.land/std@0.203.0/semver/is_semver_comparator.d.ts +12 -0
  163. package/script/deps/deno.land/std@0.203.0/semver/is_semver_comparator.js +35 -0
  164. package/script/deps/deno.land/std@0.203.0/semver/is_semver_range.d.ts +12 -0
  165. package/script/deps/deno.land/std@0.203.0/semver/is_semver_range.js +26 -0
  166. package/script/deps/deno.land/std@0.203.0/semver/lt.d.ts +3 -0
  167. package/script/deps/deno.land/std@0.203.0/semver/lt.js +9 -0
  168. package/script/deps/deno.land/std@0.203.0/semver/lte.d.ts +3 -0
  169. package/script/deps/deno.land/std@0.203.0/semver/lte.js +9 -0
  170. package/script/deps/deno.land/std@0.203.0/semver/ltr.d.ts +3 -0
  171. package/script/deps/deno.land/std@0.203.0/semver/ltr.js +9 -0
  172. package/script/deps/deno.land/std@0.203.0/semver/max_satisfying.d.ts +9 -0
  173. package/script/deps/deno.land/std@0.203.0/semver/max_satisfying.js +18 -0
  174. package/script/deps/deno.land/std@0.203.0/semver/min_satisfying.d.ts +9 -0
  175. package/script/deps/deno.land/std@0.203.0/semver/min_satisfying.js +18 -0
  176. package/script/deps/deno.land/std@0.203.0/semver/mod.d.ts +310 -0
  177. package/script/deps/deno.land/std@0.203.0/semver/mod.js +330 -0
  178. package/script/deps/deno.land/std@0.203.0/semver/neq.d.ts +3 -0
  179. package/script/deps/deno.land/std@0.203.0/semver/neq.js +9 -0
  180. package/script/deps/deno.land/std@0.203.0/semver/outside.d.ts +11 -0
  181. package/script/deps/deno.land/std@0.203.0/semver/outside.js +71 -0
  182. package/script/deps/deno.land/std@0.203.0/semver/parse.d.ts +8 -0
  183. package/script/deps/deno.land/std@0.203.0/semver/parse.js +70 -0
  184. package/script/deps/deno.land/std@0.203.0/semver/parse_comparator.d.ts +7 -0
  185. package/script/deps/deno.land/std@0.203.0/semver/parse_comparator.js +32 -0
  186. package/script/deps/deno.land/std@0.203.0/semver/parse_range.d.ts +7 -0
  187. package/script/deps/deno.land/std@0.203.0/semver/parse_range.js +296 -0
  188. package/script/deps/deno.land/std@0.203.0/semver/range_format.d.ts +8 -0
  189. package/script/deps/deno.land/std@0.203.0/semver/range_format.js +15 -0
  190. package/script/deps/deno.land/std@0.203.0/semver/range_intersects.d.ts +8 -0
  191. package/script/deps/deno.land/std@0.203.0/semver/range_intersects.js +39 -0
  192. package/script/deps/deno.land/std@0.203.0/semver/range_max.d.ts +7 -0
  193. package/script/deps/deno.land/std@0.203.0/semver/range_max.js +19 -0
  194. package/script/deps/deno.land/std@0.203.0/semver/range_min.d.ts +7 -0
  195. package/script/deps/deno.land/std@0.203.0/semver/range_min.js +18 -0
  196. package/script/deps/deno.land/std@0.203.0/semver/rcompare.d.ts +8 -0
  197. package/script/deps/deno.land/std@0.203.0/semver/rcompare.js +14 -0
  198. package/script/deps/deno.land/std@0.203.0/semver/rsort.d.ts +3 -0
  199. package/script/deps/deno.land/std@0.203.0/semver/rsort.js +9 -0
  200. package/script/deps/deno.land/std@0.203.0/semver/sort.d.ts +3 -0
  201. package/script/deps/deno.land/std@0.203.0/semver/sort.js +9 -0
  202. package/script/deps/deno.land/std@0.203.0/semver/test_comparator.d.ts +8 -0
  203. package/script/deps/deno.land/std@0.203.0/semver/test_comparator.js +14 -0
  204. package/script/deps/deno.land/std@0.203.0/semver/test_range.d.ts +8 -0
  205. package/script/deps/deno.land/std@0.203.0/semver/test_range.js +20 -0
  206. package/script/deps/deno.land/std@0.203.0/semver/types.d.ts +44 -0
  207. package/script/deps/deno.land/std@0.203.0/semver/types.js +3 -0
  208. package/script/deps/deno.land/std@0.51.0/fs/eol.d.ts +12 -0
  209. package/script/deps/deno.land/x/ini@v2.1.0/ini.d.ts +53 -0
  210. package/script/deps/deno.land/x/ini@v2.1.0/mod.d.ts +1 -0
  211. package/script/mod.d.ts +6 -0
  212. package/script/src/Change.d.ts +8 -0
  213. package/script/src/Changelog.d.ts +21 -0
  214. package/script/src/Changelog.js +24 -3
  215. package/script/src/Release.d.ts +28 -0
  216. package/script/src/Release.js +20 -21
  217. package/script/src/deps.d.ts +2 -0
  218. package/script/src/deps.js +5 -6
  219. package/script/src/parser.d.ts +11 -0
  220. package/script/test/changelog.custom.type.md +2 -3
  221. package/script/test/changelog.expected.linted.md +3 -4
  222. package/script/test/changelog.expected.md +3 -4
  223. package/script/test/changelog.md +3 -4
  224. package/script/test/empty.expected.md +2 -2
  225. package/esm/deps/deno.land/std@0.173.0/semver/mod.js +0 -1420
  226. package/script/deps/deno.land/std@0.173.0/semver/mod.js +0 -1458
  227. package/types/src/deps.d.ts +0 -1
  228. /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
  229. /package/{types → esm}/_dnt.shims.d.ts +0 -0
  230. /package/{types → esm}/bin.d.ts +0 -0
  231. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/asserts.d.ts +0 -0
  232. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
  233. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/os.d.ts +0 -0
  234. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
  235. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/flags/mod.d.ts +0 -0
  236. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_constants.d.ts +0 -0
  237. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
  238. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_interface.d.ts +0 -0
  239. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
  240. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/common.d.ts +0 -0
  241. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
  242. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/glob.d.ts +0 -0
  243. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
  244. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/separator.d.ts +0 -0
  245. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/separator.js +0 -0
  246. /package/{types → esm}/deps/deno.land/std@0.51.0/fs/eol.d.ts +0 -0
  247. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/ini.d.ts +0 -0
  248. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/mod.d.ts +0 -0
  249. /package/{types → esm}/mod.d.ts +0 -0
  250. /package/{types → esm}/src/Change.d.ts +0 -0
  251. /package/{types → esm}/src/parser.d.ts +0 -0
  252. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
  253. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
  254. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
  255. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
  256. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
  257. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
  258. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/separator.js +0 -0
package/CHANGELOG.md CHANGED
@@ -3,8 +3,27 @@
3
3
  # Changelog
4
4
  All notable changes to this project will be documented in this file.
5
5
 
6
- The format is based on [Keep a Changelog](http://keepachangelog.com/)
7
- and this project adheres to [Semantic Versioning](http://semver.org/).
6
+ The format is based on [Keep a Changelog](https://keepachangelog.com/)
7
+ and this project adheres to [Semantic Versioning](https://semver.org/).
8
+
9
+ ## [3.4.1] - 2023-10-10
10
+ ### Fixed
11
+ - Breaking changes after updating `semver` package
12
+
13
+ ## [3.4.0] - 2023-10-10
14
+ ### Added
15
+ - New function `compareLinkBuilder` [#33].
16
+
17
+ ### Fixed
18
+ - Updated dependencies
19
+
20
+ ## [2.3.0] - 2023-05-25
21
+ ### Added
22
+ - New option `--create`, to create unreleased versions [#31].
23
+
24
+ ### Fixed
25
+ - Allow empty values for `--release` option
26
+ - Updated dependencies
8
27
 
9
28
  ## [2.2.1] - 2023-01-25
10
29
  ### Fixed
@@ -44,7 +63,12 @@ New version merging Deno and Node code using Deno's `dnt` package.
44
63
  [#27]: https://github.com/oscarotero/keep-a-changelog/issues/27
45
64
  [#28]: https://github.com/oscarotero/keep-a-changelog/issues/28
46
65
  [#30]: https://github.com/oscarotero/keep-a-changelog/issues/30
66
+ [#31]: https://github.com/oscarotero/keep-a-changelog/issues/31
67
+ [#33]: https://github.com/oscarotero/keep-a-changelog/issues/33
47
68
 
69
+ [3.4.1]: https://github.com/oscarotero/keep-a-changelog/compare/v3.4.0...v3.4.1
70
+ [3.4.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.3.0...v3.4.0
71
+ [2.3.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.2.1...v2.3.0
48
72
  [2.2.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.2.0...v2.2.1
49
73
  [2.2.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.1.0...v2.2.0
50
74
  [2.1.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.0.1...v2.1.0
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  Node & Deno
5
5
 
6
6
  Deno package to parse and generate changelogs following the
7
- [keepachangelog](http://keepachangelog.com/en/1.0.0/) format.
7
+ [keepachangelog](https://keepachangelog.com/) format.
8
8
 
9
9
  ## Usage in Node
10
10
 
@@ -22,7 +22,7 @@ console.log(changelog.toString());
22
22
  ## Usage in Deno
23
23
 
24
24
  ```js
25
- import { parser } from "https://deno.land/x/changelog@v2.0.0/mod.ts";
25
+ import { parser } from "https://deno.land/x/changelog@v2.2.1/mod.ts";
26
26
 
27
27
  //Parse a changelog file
28
28
  const changelog = parser(await Deno.readTextFile("CHANGELOG.md"));
@@ -37,7 +37,7 @@ console.log(changelog.toString());
37
37
  import {
38
38
  Changelog,
39
39
  Release,
40
- } from "https://deno.land/x/changelog@v2.0.0/mod.ts";
40
+ } from "https://deno.land/x/changelog@v2.2.1/mod.ts";
41
41
 
42
42
  const changelog = new Changelog("My project")
43
43
  .addRelease(
@@ -78,11 +78,23 @@ const changelog = new Changelog();
78
78
  changelog.tagNameBuilder = (release) => `version-${release.version}`;
79
79
  ```
80
80
 
81
+ ### Custom compare links
82
+
83
+ By default, compare links are build compliant with GitHub format. To change this
84
+ behavior, set a new `compareLinkBuilder`:
85
+
86
+ ```js
87
+ const changelog = new Changelog();
88
+ changelog.url = "https://bitbucket.org/oscarotero/keep-a-changelog";
89
+ changelog.compareLinkBuilder = (previous, release) =>
90
+ `${this.url}/branches/compare/${release.version}%0D${previous.version}`;
91
+ ```
92
+
81
93
  ### Custom Change Types
82
94
 
83
- By default and according to the
84
- [keepachangelog](http://keepachangelog.com/en/1.0.0/) format, the change types
85
- are `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, and `Security`.
95
+ By default and according to the [keepachangelog](https://keepachangelog.com/)
96
+ format, the change types are `Added`, `Changed`, `Deprecated`, `Removed`,
97
+ `Fixed`, and `Security`.
86
98
 
87
99
  In case you'd like add another type, you need to extend the `Release` class to
88
100
  support new types. Additionally, you have to tell the `parser` that it should
@@ -160,6 +172,12 @@ You can release automatically the latest "Unreleased" version:
160
172
  changelog --release
161
173
  ```
162
174
 
175
+ If your "Unreleased" section has no version, you can specify it as an argument:
176
+
177
+ ```sh
178
+ changelog --release 2.0.0
179
+ ```
180
+
163
181
  And return the latest released version:
164
182
 
165
183
  ```sh
@@ -171,11 +189,12 @@ Available options:
171
189
 
172
190
  | Option | Description |
173
191
  | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
174
- | `--format` | The output format for the generated markdown. It can be `markdownlint` or `compact`. The default value is `compact`. |
192
+ | `--format` | The output format for the generated markdown. It can be `markdownlint` or `compact`. The default value is `compact`. |
175
193
  | `--file` | The markdown file of the changelog. The default value is `CHANGELOG.md`. |
176
194
  | `--url` | The base url used to build the diff urls of the different releases. It is taken from the existing diff urls in the markdown. If no urls are found, try to catch it using the url of the git remote repository. |
177
195
  | `--https` | Set to false to use `http` instead `https` in the url (`--https=false`). |
178
196
  | `--init` | Init a new empty changelog file. |
179
197
  | `--latest-release` | Print the latest release version. |
180
- | `--release` | Updated the latest unreleased version with the current date. |
198
+ | `--release` | Updated the latest unreleased version with the current date. Use `--release=X.Y.Z` to set a number if the version doesn't have it. |
199
+ | `--create` | Create a new Unreleased version. Use `--create=X.Y.Z` to specify a version number or just `--create` for a version without number. |
181
200
  | `--quiet` | Do not output error messages |
package/esm/_dnt.shims.js CHANGED
@@ -4,7 +4,6 @@ const dntGlobals = {
4
4
  Deno,
5
5
  };
6
6
  export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
7
- // deno-lint-ignore ban-types
8
7
  function createMergeProxy(baseObj, extObj) {
9
8
  return new Proxy(baseObj, {
10
9
  get(_target, prop, _receiver) {
package/esm/bin.js CHANGED
@@ -1,20 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import "./_dnt.polyfills.js";
3
3
  import * as dntShim from "./_dnt.shims.js";
4
- import { join } from "./deps/deno.land/std@0.173.0/path/mod.js";
4
+ import { join } from "./deps/deno.land/std@0.189.0/path/mod.js";
5
5
  import { Changelog, parser, Release } from "./mod.js";
6
- import { parse as parseFlag } from "./deps/deno.land/std@0.173.0/flags/mod.js";
6
+ import { parse as parseFlag } from "./deps/deno.land/std@0.189.0/flags/mod.js";
7
7
  import { parse as parseIni } from "./deps/deno.land/x/ini@v2.1.0/mod.js";
8
8
  const argv = parseFlag(dntShim.Deno.args, {
9
9
  default: {
10
10
  file: "CHANGELOG.md",
11
11
  format: "compact",
12
12
  release: null,
13
+ create: null,
13
14
  url: null,
14
15
  https: true,
15
16
  quiet: false,
16
17
  },
17
- string: ["file", "format", "release", "url"],
18
+ string: ["file", "format", "url"],
18
19
  boolean: ["https", "init", "latest-release", "quiet"],
19
20
  });
20
21
  const file = join(dntShim.Deno.cwd(), argv.file);
@@ -55,6 +56,10 @@ try {
55
56
  dntShim.Deno.exit(1);
56
57
  }
57
58
  }
59
+ if (argv.create) {
60
+ const version = typeof argv.create === "string" ? argv.create : undefined;
61
+ changelog.addRelease(new Release(version));
62
+ }
58
63
  if (!changelog.url) {
59
64
  if (argv.url) {
60
65
  changelog.url = argv.url;
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  /**
3
4
  * Command line arguments parser based on
4
5
  * [minimist](https://github.com/minimistjs/minimist).
@@ -330,10 +331,10 @@ export function parse(args, { "--": doubleDash = false, alias = {}, boolean = fa
330
331
  }
331
332
  for (const [key, value] of Object.entries(defaults)) {
332
333
  if (!hasKey(argv, key.split("."))) {
333
- setKey(argv, key, value);
334
+ setKey(argv, key, value, false);
334
335
  if (aliases[key]) {
335
336
  for (const x of aliases[key]) {
336
- setKey(argv, x, value);
337
+ setKey(argv, x, value, false);
337
338
  }
338
339
  }
339
340
  }
@@ -6,3 +6,6 @@ export declare function isWindowsDeviceRoot(code: number): boolean;
6
6
  export declare function normalizeString(path: string, allowAboveRoot: boolean, separator: string, isPathSeparator: (code: number) => boolean): string;
7
7
  export declare function _format(sep: string, pathObject: FormatInputPathObject): string;
8
8
  export declare function encodeWhitespace(string: string): string;
9
+ export declare function lastPathSegment(path: string, isSep: (char: number) => boolean, start?: number): string;
10
+ export declare function stripTrailingSeparators(segment: string, isSep: (char: number) => boolean): string;
11
+ export declare function stripSuffix(name: string, suffix: string): string;
@@ -96,6 +96,8 @@ export function _format(sep, pathObject) {
96
96
  (pathObject.name || "") + (pathObject.ext || "");
97
97
  if (!dir)
98
98
  return base;
99
+ if (base === sep)
100
+ return dir;
99
101
  if (dir === pathObject.root)
100
102
  return dir + base;
101
103
  return dir + sep + base;
@@ -113,3 +115,47 @@ export function encodeWhitespace(string) {
113
115
  return WHITESPACE_ENCODINGS[c] ?? c;
114
116
  });
115
117
  }
118
+ export function lastPathSegment(path, isSep, start = 0) {
119
+ let matchedNonSeparator = false;
120
+ let end = path.length;
121
+ for (let i = path.length - 1; i >= start; --i) {
122
+ if (isSep(path.charCodeAt(i))) {
123
+ if (matchedNonSeparator) {
124
+ start = i + 1;
125
+ break;
126
+ }
127
+ }
128
+ else if (!matchedNonSeparator) {
129
+ matchedNonSeparator = true;
130
+ end = i + 1;
131
+ }
132
+ }
133
+ return path.slice(start, end);
134
+ }
135
+ export function stripTrailingSeparators(segment, isSep) {
136
+ if (segment.length <= 1) {
137
+ return segment;
138
+ }
139
+ let end = segment.length;
140
+ for (let i = segment.length - 1; i > 0; i--) {
141
+ if (isSep(segment.charCodeAt(i))) {
142
+ end = i;
143
+ }
144
+ else {
145
+ break;
146
+ }
147
+ }
148
+ return segment.slice(0, end);
149
+ }
150
+ export function stripSuffix(name, suffix) {
151
+ if (suffix.length >= name.length) {
152
+ return name;
153
+ }
154
+ const lenDiff = name.length - suffix.length;
155
+ for (let i = suffix.length - 1; i >= 0; --i) {
156
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
157
+ return name;
158
+ }
159
+ }
160
+ return name.slice(0, -suffix.length);
161
+ }
@@ -2,7 +2,9 @@ import * as _win32 from "./win32.js";
2
2
  import * as _posix from "./posix.js";
3
3
  export declare const win32: typeof _win32;
4
4
  export declare const posix: typeof _posix;
5
- export declare const basename: typeof _posix.basename | typeof _win32.basename, delimiter: string, dirname: typeof _posix.dirname | typeof _win32.dirname, extname: typeof _posix.extname | typeof _win32.extname, format: typeof _posix.format | typeof _win32.format, fromFileUrl: typeof _posix.fromFileUrl | typeof _win32.fromFileUrl, isAbsolute: typeof _win32.isAbsolute | typeof _posix.isAbsolute, join: typeof _posix.join | typeof _win32.join, normalize: typeof _win32.normalize | typeof _posix.normalize, parse: typeof _posix.parse | typeof _win32.parse, relative: typeof _posix.relative | typeof _win32.relative, resolve: typeof _win32.resolve | typeof _posix.resolve, sep: string, toFileUrl: typeof _posix.toFileUrl | typeof _win32.toFileUrl, toNamespacedPath: typeof _posix.toNamespacedPath | typeof _win32.toNamespacedPath;
5
+ export declare const basename: typeof _posix.basename | typeof _win32.basename, delimiter: string, dirname: typeof _posix.dirname | typeof _win32.dirname, extname: typeof _posix.extname | typeof _win32.extname, format: typeof _posix.format | typeof _win32.format, fromFileUrl: typeof _posix.fromFileUrl | typeof _win32.fromFileUrl, isAbsolute: typeof _win32.isAbsolute | typeof _posix.isAbsolute, join: typeof _posix.join | typeof _win32.join, normalize: typeof _win32.normalize | typeof _posix.normalize, parse: typeof _posix.parse | typeof _win32.parse, relative: typeof _posix.relative | typeof _win32.relative, resolve: typeof _win32.resolve | typeof _posix.resolve, toFileUrl: typeof _posix.toFileUrl | typeof _win32.toFileUrl, toNamespacedPath: typeof _posix.toNamespacedPath | typeof _win32.toNamespacedPath;
6
+ /** @deprecated (will be removed after 0.188.0) Use SEP intead. */
7
+ export declare const sep: string;
6
8
  export * from "./common.js";
7
9
  export { SEP, SEP_PATTERN } from "./separator.js";
8
10
  export * from "./_interface.js";
@@ -1,6 +1,7 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
2
  // Copyright the Browserify authors. MIT License.
3
3
  // Ported mostly from https://github.com/browserify/path-browserify/
4
+ // This module is browser compatible.
4
5
  /**
5
6
  * Utilities for working with OS-specific file paths.
6
7
  *
@@ -25,7 +26,9 @@ import * as _posix from "./posix.js";
25
26
  const path = isWindows ? _win32 : _posix;
26
27
  export const win32 = _win32;
27
28
  export const posix = _posix;
28
- export const { basename, delimiter, dirname, extname, format, fromFileUrl, isAbsolute, join, normalize, parse, relative, resolve, sep, toFileUrl, toNamespacedPath, } = path;
29
+ export const { basename, delimiter, dirname, extname, format, fromFileUrl, isAbsolute, join, normalize, parse, relative, resolve, toFileUrl, toNamespacedPath, } = path;
30
+ /** @deprecated (will be removed after 0.188.0) Use SEP intead. */
31
+ export const sep = path.sep;
29
32
  export * from "./common.js";
30
33
  export { SEP, SEP_PATTERN } from "./separator.js";
31
34
  export * from "./_interface.js";
@@ -37,15 +37,17 @@ export declare function relative(from: string, to: string): string;
37
37
  export declare function toNamespacedPath(path: string): string;
38
38
  /**
39
39
  * Return the directory path of a `path`.
40
- * @param path to determine the directory path for
40
+ * @param path - path to extract the directory from.
41
41
  */
42
42
  export declare function dirname(path: string): string;
43
43
  /**
44
- * Return the last portion of a `path`. Trailing directory separators are ignored.
45
- * @param path to process
46
- * @param ext of path directory
44
+ * Return the last portion of a `path`.
45
+ * Trailing directory separators are ignored, and optional suffix is removed.
46
+ *
47
+ * @param path - path to extract the name from.
48
+ * @param [suffix] - suffix to remove from extracted name.
47
49
  */
48
- export declare function basename(path: string, ext?: string): string;
50
+ export declare function basename(path: string, suffix?: string): string;
49
51
  /**
50
52
  * Return the extension of the `path` with leading period.
51
53
  * @param path with extension
@@ -3,8 +3,8 @@
3
3
  // Ported from https://github.com/browserify/path-browserify/
4
4
  // This module is browser compatible.
5
5
  import * as dntShim from "../../../../_dnt.shims.js";
6
- import { CHAR_DOT, CHAR_FORWARD_SLASH } from "./_constants.js";
7
- import { _format, assertPath, encodeWhitespace, isPosixPathSeparator, normalizeString, } from "./_util.js";
6
+ import { CHAR_DOT } from "./_constants.js";
7
+ import { _format, assertPath, encodeWhitespace, isPosixPathSeparator, lastPathSegment, normalizeString, stripSuffix, stripTrailingSeparators, } from "./_util.js";
8
8
  export const sep = "/";
9
9
  export const delimiter = ":";
10
10
  // path.resolve([from ...], to)
@@ -33,7 +33,7 @@ export function resolve(...pathSegments) {
33
33
  continue;
34
34
  }
35
35
  resolvedPath = `${path}/${resolvedPath}`;
36
- resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
36
+ resolvedAbsolute = isPosixPathSeparator(path.charCodeAt(0));
37
37
  }
38
38
  // At this point the path should be resolved to a full absolute path, but
39
39
  // handle relative paths to be safe (might happen when process.cwd() fails)
@@ -60,8 +60,8 @@ export function normalize(path) {
60
60
  assertPath(path);
61
61
  if (path.length === 0)
62
62
  return ".";
63
- const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
64
- const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
63
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
64
+ const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1));
65
65
  // Normalize the path
66
66
  path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
67
67
  if (path.length === 0 && !isAbsolute)
@@ -78,7 +78,7 @@ export function normalize(path) {
78
78
  */
79
79
  export function isAbsolute(path) {
80
80
  assertPath(path);
81
- return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
81
+ return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
82
82
  }
83
83
  /**
84
84
  * Join all given a sequence of `paths`,then normalizes the resulting path.
@@ -120,7 +120,7 @@ export function relative(from, to) {
120
120
  let fromStart = 1;
121
121
  const fromEnd = from.length;
122
122
  for (; fromStart < fromEnd; ++fromStart) {
123
- if (from.charCodeAt(fromStart) !== CHAR_FORWARD_SLASH)
123
+ if (!isPosixPathSeparator(from.charCodeAt(fromStart)))
124
124
  break;
125
125
  }
126
126
  const fromLen = fromEnd - fromStart;
@@ -128,7 +128,7 @@ export function relative(from, to) {
128
128
  let toStart = 1;
129
129
  const toEnd = to.length;
130
130
  for (; toStart < toEnd; ++toStart) {
131
- if (to.charCodeAt(toStart) !== CHAR_FORWARD_SLASH)
131
+ if (!isPosixPathSeparator(to.charCodeAt(toStart)))
132
132
  break;
133
133
  }
134
134
  const toLen = toEnd - toStart;
@@ -139,7 +139,7 @@ export function relative(from, to) {
139
139
  for (; i <= length; ++i) {
140
140
  if (i === length) {
141
141
  if (toLen > length) {
142
- if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
142
+ if (isPosixPathSeparator(to.charCodeAt(toStart + i))) {
143
143
  // We get here if `from` is the exact base path for `to`.
144
144
  // For example: from='/foo/bar'; to='/foo/bar/baz'
145
145
  return to.slice(toStart + i + 1);
@@ -151,7 +151,7 @@ export function relative(from, to) {
151
151
  }
152
152
  }
153
153
  else if (fromLen > length) {
154
- if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
154
+ if (isPosixPathSeparator(from.charCodeAt(fromStart + i))) {
155
155
  // We get here if `to` is the exact base path for `from`.
156
156
  // For example: from='/foo/bar/baz'; to='/foo/bar'
157
157
  lastCommonSep = i;
@@ -168,14 +168,14 @@ export function relative(from, to) {
168
168
  const toCode = to.charCodeAt(toStart + i);
169
169
  if (fromCode !== toCode)
170
170
  break;
171
- else if (fromCode === CHAR_FORWARD_SLASH)
171
+ else if (isPosixPathSeparator(fromCode))
172
172
  lastCommonSep = i;
173
173
  }
174
174
  let out = "";
175
175
  // Generate the relative path based on the path difference between `to`
176
176
  // and `from`
177
177
  for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
178
- if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
178
+ if (i === fromEnd || isPosixPathSeparator(from.charCodeAt(i))) {
179
179
  if (out.length === 0)
180
180
  out += "..";
181
181
  else
@@ -188,7 +188,7 @@ export function relative(from, to) {
188
188
  return out + to.slice(toStart + lastCommonSep);
189
189
  else {
190
190
  toStart += lastCommonSep;
191
- if (to.charCodeAt(toStart) === CHAR_FORWARD_SLASH)
191
+ if (isPosixPathSeparator(to.charCodeAt(toStart)))
192
192
  ++toStart;
193
193
  return to.slice(toStart);
194
194
  }
@@ -203,114 +203,53 @@ export function toNamespacedPath(path) {
203
203
  }
204
204
  /**
205
205
  * Return the directory path of a `path`.
206
- * @param path to determine the directory path for
206
+ * @param path - path to extract the directory from.
207
207
  */
208
208
  export function dirname(path) {
209
- assertPath(path);
210
209
  if (path.length === 0)
211
210
  return ".";
212
- const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
213
211
  let end = -1;
214
- let matchedSlash = true;
212
+ let matchedNonSeparator = false;
215
213
  for (let i = path.length - 1; i >= 1; --i) {
216
- if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
217
- if (!matchedSlash) {
214
+ if (isPosixPathSeparator(path.charCodeAt(i))) {
215
+ if (matchedNonSeparator) {
218
216
  end = i;
219
217
  break;
220
218
  }
221
219
  }
222
220
  else {
223
- // We saw the first non-path separator
224
- matchedSlash = false;
221
+ matchedNonSeparator = true;
225
222
  }
226
223
  }
227
- if (end === -1)
228
- return hasRoot ? "/" : ".";
229
- if (hasRoot && end === 1)
230
- return "//";
231
- return path.slice(0, end);
224
+ // No matches. Fallback based on provided path:
225
+ //
226
+ // - leading slashes paths
227
+ // "/foo" => "/"
228
+ // "///foo" => "/"
229
+ // - no slash path
230
+ // "foo" => "."
231
+ if (end === -1) {
232
+ return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
233
+ }
234
+ return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
232
235
  }
233
236
  /**
234
- * Return the last portion of a `path`. Trailing directory separators are ignored.
235
- * @param path to process
236
- * @param ext of path directory
237
+ * Return the last portion of a `path`.
238
+ * Trailing directory separators are ignored, and optional suffix is removed.
239
+ *
240
+ * @param path - path to extract the name from.
241
+ * @param [suffix] - suffix to remove from extracted name.
237
242
  */
238
- export function basename(path, ext = "") {
239
- if (ext !== undefined && typeof ext !== "string") {
240
- throw new TypeError('"ext" argument must be a string');
241
- }
243
+ export function basename(path, suffix = "") {
242
244
  assertPath(path);
243
- let start = 0;
244
- let end = -1;
245
- let matchedSlash = true;
246
- let i;
247
- if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
248
- if (ext.length === path.length && ext === path)
249
- return "";
250
- let extIdx = ext.length - 1;
251
- let firstNonSlashEnd = -1;
252
- for (i = path.length - 1; i >= 0; --i) {
253
- const code = path.charCodeAt(i);
254
- if (isPosixPathSeparator(code)) {
255
- // If we reached a path separator that was not part of a set of path
256
- // separators at the end of the string, stop now
257
- if (!matchedSlash) {
258
- start = i + 1;
259
- break;
260
- }
261
- }
262
- else {
263
- if (firstNonSlashEnd === -1) {
264
- // We saw the first non-path separator, mark this as the end of our
265
- // path component in case we don't match a whole suffix
266
- matchedSlash = false;
267
- firstNonSlashEnd = i + 1;
268
- end = firstNonSlashEnd;
269
- }
270
- if (extIdx >= 0) {
271
- // Try to match the explicit suffix
272
- if (code === ext.charCodeAt(extIdx)) {
273
- if (--extIdx === -1) {
274
- // We matched whole suffix, so mark this as the end of our path
275
- // component
276
- end = i;
277
- }
278
- }
279
- else {
280
- // Suffix character does not match, so bail out early
281
- // from checking rest of characters
282
- extIdx = -1;
283
- }
284
- }
285
- }
286
- }
287
- if (end === -1)
288
- return "";
289
- if (start === end)
290
- end = firstNonSlashEnd;
291
- return path.slice(start, end);
292
- }
293
- else {
294
- for (i = path.length - 1; i >= 0; --i) {
295
- if (isPosixPathSeparator(path.charCodeAt(i))) {
296
- // If we reached a path separator that was not part of a set of path
297
- // separators at the end of the string, stop now
298
- if (!matchedSlash) {
299
- start = i + 1;
300
- break;
301
- }
302
- }
303
- else if (end === -1) {
304
- // We saw the first non-path separator, mark this as the end of our
305
- // path component
306
- matchedSlash = false;
307
- end = i + 1;
308
- }
309
- }
310
- if (end === -1)
311
- return "";
312
- return path.slice(start, end);
245
+ if (path.length === 0)
246
+ return path;
247
+ if (typeof suffix !== "string") {
248
+ throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);
313
249
  }
250
+ const lastSegment = lastPathSegment(path, isPosixPathSeparator);
251
+ const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator);
252
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
314
253
  }
315
254
  /**
316
255
  * Return the extension of the `path` with leading period.
@@ -328,7 +267,7 @@ export function extname(path) {
328
267
  let preDotState = 0;
329
268
  for (let i = path.length - 1; i >= 0; --i) {
330
269
  const code = path.charCodeAt(i);
331
- if (code === CHAR_FORWARD_SLASH) {
270
+ if (isPosixPathSeparator(code)) {
332
271
  // If we reached a path separator that was not part of a set of path
333
272
  // separators at the end of the string, stop now
334
273
  if (!matchedSlash) {
@@ -385,7 +324,7 @@ export function parse(path) {
385
324
  const ret = { root: "", dir: "", base: "", ext: "", name: "" };
386
325
  if (path.length === 0)
387
326
  return ret;
388
- const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
327
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
389
328
  let start;
390
329
  if (isAbsolute) {
391
330
  ret.root = "/";
@@ -405,7 +344,7 @@ export function parse(path) {
405
344
  // Get non-dir info
406
345
  for (; i >= start; --i) {
407
346
  const code = path.charCodeAt(i);
408
- if (code === CHAR_FORWARD_SLASH) {
347
+ if (isPosixPathSeparator(code)) {
409
348
  // If we reached a path separator that was not part of a set of path
410
349
  // separators at the end of the string, stop now
411
350
  if (!matchedSlash) {
@@ -447,6 +386,8 @@ export function parse(path) {
447
386
  ret.base = ret.name = path.slice(startPart, end);
448
387
  }
449
388
  }
389
+ // Fallback to '/' in case there is no basename
390
+ ret.base = ret.base || "/";
450
391
  }
451
392
  else {
452
393
  if (startPart === 0 && isAbsolute) {
@@ -459,8 +400,9 @@ export function parse(path) {
459
400
  }
460
401
  ret.ext = path.slice(startDot, end);
461
402
  }
462
- if (startPart > 0)
463
- ret.dir = path.slice(0, startPart - 1);
403
+ if (startPart > 0) {
404
+ ret.dir = stripTrailingSeparators(path.slice(0, startPart - 1), isPosixPathSeparator);
405
+ }
464
406
  else if (isAbsolute)
465
407
  ret.dir = "/";
466
408
  return ret;
@@ -38,15 +38,17 @@ export declare function relative(from: string, to: string): string;
38
38
  export declare function toNamespacedPath(path: string): string;
39
39
  /**
40
40
  * Return the directory path of a `path`.
41
- * @param path to determine the directory path for
41
+ * @param path - path to extract the directory from.
42
42
  */
43
43
  export declare function dirname(path: string): string;
44
44
  /**
45
- * Return the last portion of a `path`. Trailing directory separators are ignored.
46
- * @param path to process
47
- * @param ext of path directory
45
+ * Return the last portion of a `path`.
46
+ * Trailing directory separators are ignored, and optional suffix is removed.
47
+ *
48
+ * @param path - path to extract name from.
49
+ * @param [suffix] - suffix to remove from extracted name.
48
50
  */
49
- export declare function basename(path: string, ext?: string): string;
51
+ export declare function basename(path: string, suffix?: string): string;
50
52
  /**
51
53
  * Return the extension of the `path` with leading period.
52
54
  * @param path with extension