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.
- package/CHANGELOG.md +26 -2
- package/README.md +27 -8
- package/esm/_dnt.shims.js +0 -1
- package/esm/bin.js +8 -3
- package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +3 -2
- package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_util.d.ts +3 -0
- package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +46 -0
- package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/mod.d.ts +3 -1
- package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +4 -1
- package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/posix.d.ts +7 -5
- package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +50 -108
- package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/win32.d.ts +7 -5
- package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +23 -82
- package/esm/deps/deno.land/std@0.203.0/semver/_shared.d.ts +42 -0
- package/esm/deps/deno.land/std@0.203.0/semver/_shared.js +230 -0
- package/esm/deps/deno.land/std@0.203.0/semver/cmp.d.ts +9 -0
- package/esm/deps/deno.land/std@0.203.0/semver/cmp.js +35 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_format.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_format.js +11 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_intersects.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_intersects.js +45 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_max.d.ts +9 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_max.js +45 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_min.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/comparator_min.js +32 -0
- package/esm/deps/deno.land/std@0.203.0/semver/compare.d.ts +10 -0
- package/esm/deps/deno.land/std@0.203.0/semver/compare.js +18 -0
- package/esm/deps/deno.land/std@0.203.0/semver/compare_build.d.ts +13 -0
- package/esm/deps/deno.land/std@0.203.0/semver/compare_build.js +23 -0
- package/esm/deps/deno.land/std@0.203.0/semver/constants.d.ts +42 -0
- package/esm/deps/deno.land/std@0.203.0/semver/constants.js +75 -0
- package/esm/deps/deno.land/std@0.203.0/semver/difference.d.ts +4 -0
- package/esm/deps/deno.land/std@0.203.0/semver/difference.js +26 -0
- package/esm/deps/deno.land/std@0.203.0/semver/eq.d.ts +4 -0
- package/esm/deps/deno.land/std@0.203.0/semver/eq.js +7 -0
- package/esm/deps/deno.land/std@0.203.0/semver/format.d.ts +12 -0
- package/esm/deps/deno.land/std@0.203.0/semver/format.js +54 -0
- package/esm/deps/deno.land/std@0.203.0/semver/gt.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/gt.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/gte.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/gte.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/gtr.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/gtr.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/increment.d.ts +28 -0
- package/esm/deps/deno.land/std@0.203.0/semver/increment.js +207 -0
- package/esm/deps/deno.land/std@0.203.0/semver/is_semver.d.ts +17 -0
- package/esm/deps/deno.land/std@0.203.0/semver/is_semver.js +41 -0
- package/esm/deps/deno.land/std@0.203.0/semver/is_semver_comparator.d.ts +12 -0
- package/esm/deps/deno.land/std@0.203.0/semver/is_semver_comparator.js +31 -0
- package/esm/deps/deno.land/std@0.203.0/semver/is_semver_range.d.ts +12 -0
- package/esm/deps/deno.land/std@0.203.0/semver/is_semver_range.js +22 -0
- package/esm/deps/deno.land/std@0.203.0/semver/lt.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/lt.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/lte.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/lte.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/ltr.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/ltr.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/max_satisfying.d.ts +9 -0
- package/esm/deps/deno.land/std@0.203.0/semver/max_satisfying.js +14 -0
- package/esm/deps/deno.land/std@0.203.0/semver/min_satisfying.d.ts +9 -0
- package/esm/deps/deno.land/std@0.203.0/semver/min_satisfying.js +14 -0
- package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.203.0}/semver/mod.d.ts +88 -176
- package/esm/deps/deno.land/std@0.203.0/semver/mod.js +313 -0
- package/esm/deps/deno.land/std@0.203.0/semver/neq.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/neq.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/outside.d.ts +11 -0
- package/esm/deps/deno.land/std@0.203.0/semver/outside.js +67 -0
- package/esm/deps/deno.land/std@0.203.0/semver/parse.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/parse.js +66 -0
- package/esm/deps/deno.land/std@0.203.0/semver/parse_comparator.d.ts +7 -0
- package/esm/deps/deno.land/std@0.203.0/semver/parse_comparator.js +28 -0
- package/esm/deps/deno.land/std@0.203.0/semver/parse_range.d.ts +7 -0
- package/esm/deps/deno.land/std@0.203.0/semver/parse_range.js +292 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_format.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_format.js +11 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_intersects.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_intersects.js +35 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_max.d.ts +7 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_max.js +15 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_min.d.ts +7 -0
- package/esm/deps/deno.land/std@0.203.0/semver/range_min.js +14 -0
- package/esm/deps/deno.land/std@0.203.0/semver/rcompare.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/rcompare.js +10 -0
- package/esm/deps/deno.land/std@0.203.0/semver/rsort.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/rsort.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/sort.d.ts +3 -0
- package/esm/deps/deno.land/std@0.203.0/semver/sort.js +5 -0
- package/esm/deps/deno.land/std@0.203.0/semver/test_comparator.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/test_comparator.js +10 -0
- package/esm/deps/deno.land/std@0.203.0/semver/test_range.d.ts +8 -0
- package/esm/deps/deno.land/std@0.203.0/semver/test_range.js +16 -0
- package/esm/deps/deno.land/std@0.203.0/semver/types.d.ts +44 -0
- package/esm/deps/deno.land/std@0.203.0/semver/types.js +2 -0
- package/{types → esm}/src/Changelog.d.ts +4 -2
- package/esm/src/Changelog.js +25 -4
- package/{types → esm}/src/Release.d.ts +5 -4
- package/esm/src/Release.js +21 -22
- package/esm/src/deps.d.ts +2 -0
- package/esm/src/deps.js +1 -1
- package/esm/test/changelog.custom.type.md +2 -3
- package/esm/test/changelog.expected.linted.md +3 -4
- package/esm/test/changelog.expected.md +3 -4
- package/esm/test/changelog.md +3 -4
- package/esm/test/empty.expected.md +2 -2
- package/package.json +6 -13
- package/script/_dnt.polyfills.d.ts +11 -0
- package/script/_dnt.shims.d.ts +5 -0
- package/script/_dnt.shims.js +0 -1
- package/script/bin.d.ts +2 -0
- package/script/bin.js +8 -3
- package/script/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
- package/script/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
- package/script/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
- package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +4 -3
- package/script/deps/deno.land/std@0.189.0/path/_constants.d.ts +39 -0
- package/script/deps/deno.land/std@0.189.0/path/_interface.d.ts +26 -0
- package/script/deps/deno.land/std@0.189.0/path/_util.d.ts +11 -0
- package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +50 -1
- package/script/deps/deno.land/std@0.189.0/path/common.d.ts +13 -0
- package/script/deps/deno.land/std@0.189.0/path/glob.d.ts +83 -0
- package/script/deps/deno.land/std@0.189.0/path/mod.d.ts +11 -0
- package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +5 -2
- package/script/deps/deno.land/std@0.189.0/path/posix.d.ts +86 -0
- package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +48 -106
- package/script/deps/deno.land/std@0.189.0/path/separator.d.ts +2 -0
- package/script/deps/deno.land/std@0.189.0/path/win32.d.ts +91 -0
- package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +22 -81
- package/script/deps/deno.land/std@0.203.0/semver/_shared.d.ts +42 -0
- package/script/deps/deno.land/std@0.203.0/semver/_shared.js +248 -0
- package/script/deps/deno.land/std@0.203.0/semver/cmp.d.ts +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/cmp.js +39 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_format.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_format.js +15 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_intersects.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_intersects.js +49 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_max.d.ts +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_max.js +49 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_min.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/comparator_min.js +36 -0
- package/script/deps/deno.land/std@0.203.0/semver/compare.d.ts +10 -0
- package/script/deps/deno.land/std@0.203.0/semver/compare.js +22 -0
- package/script/deps/deno.land/std@0.203.0/semver/compare_build.d.ts +13 -0
- package/script/deps/deno.land/std@0.203.0/semver/compare_build.js +27 -0
- package/script/deps/deno.land/std@0.203.0/semver/constants.d.ts +42 -0
- package/script/deps/deno.land/std@0.203.0/semver/constants.js +78 -0
- package/script/deps/deno.land/std@0.203.0/semver/difference.d.ts +4 -0
- package/script/deps/deno.land/std@0.203.0/semver/difference.js +30 -0
- package/script/deps/deno.land/std@0.203.0/semver/eq.d.ts +4 -0
- package/script/deps/deno.land/std@0.203.0/semver/eq.js +11 -0
- package/script/deps/deno.land/std@0.203.0/semver/format.d.ts +12 -0
- package/script/deps/deno.land/std@0.203.0/semver/format.js +58 -0
- package/script/deps/deno.land/std@0.203.0/semver/gt.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/gt.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/gte.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/gte.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/gtr.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/gtr.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/increment.d.ts +28 -0
- package/script/deps/deno.land/std@0.203.0/semver/increment.js +211 -0
- package/script/deps/deno.land/std@0.203.0/semver/is_semver.d.ts +17 -0
- package/script/deps/deno.land/std@0.203.0/semver/is_semver.js +45 -0
- package/script/deps/deno.land/std@0.203.0/semver/is_semver_comparator.d.ts +12 -0
- package/script/deps/deno.land/std@0.203.0/semver/is_semver_comparator.js +35 -0
- package/script/deps/deno.land/std@0.203.0/semver/is_semver_range.d.ts +12 -0
- package/script/deps/deno.land/std@0.203.0/semver/is_semver_range.js +26 -0
- package/script/deps/deno.land/std@0.203.0/semver/lt.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/lt.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/lte.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/lte.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/ltr.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/ltr.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/max_satisfying.d.ts +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/max_satisfying.js +18 -0
- package/script/deps/deno.land/std@0.203.0/semver/min_satisfying.d.ts +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/min_satisfying.js +18 -0
- package/script/deps/deno.land/std@0.203.0/semver/mod.d.ts +310 -0
- package/script/deps/deno.land/std@0.203.0/semver/mod.js +330 -0
- package/script/deps/deno.land/std@0.203.0/semver/neq.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/neq.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/outside.d.ts +11 -0
- package/script/deps/deno.land/std@0.203.0/semver/outside.js +71 -0
- package/script/deps/deno.land/std@0.203.0/semver/parse.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/parse.js +70 -0
- package/script/deps/deno.land/std@0.203.0/semver/parse_comparator.d.ts +7 -0
- package/script/deps/deno.land/std@0.203.0/semver/parse_comparator.js +32 -0
- package/script/deps/deno.land/std@0.203.0/semver/parse_range.d.ts +7 -0
- package/script/deps/deno.land/std@0.203.0/semver/parse_range.js +296 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_format.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_format.js +15 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_intersects.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_intersects.js +39 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_max.d.ts +7 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_max.js +19 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_min.d.ts +7 -0
- package/script/deps/deno.land/std@0.203.0/semver/range_min.js +18 -0
- package/script/deps/deno.land/std@0.203.0/semver/rcompare.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/rcompare.js +14 -0
- package/script/deps/deno.land/std@0.203.0/semver/rsort.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/rsort.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/sort.d.ts +3 -0
- package/script/deps/deno.land/std@0.203.0/semver/sort.js +9 -0
- package/script/deps/deno.land/std@0.203.0/semver/test_comparator.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/test_comparator.js +14 -0
- package/script/deps/deno.land/std@0.203.0/semver/test_range.d.ts +8 -0
- package/script/deps/deno.land/std@0.203.0/semver/test_range.js +20 -0
- package/script/deps/deno.land/std@0.203.0/semver/types.d.ts +44 -0
- package/script/deps/deno.land/std@0.203.0/semver/types.js +3 -0
- package/script/deps/deno.land/std@0.51.0/fs/eol.d.ts +12 -0
- package/script/deps/deno.land/x/ini@v2.1.0/ini.d.ts +53 -0
- package/script/deps/deno.land/x/ini@v2.1.0/mod.d.ts +1 -0
- package/script/mod.d.ts +6 -0
- package/script/src/Change.d.ts +8 -0
- package/script/src/Changelog.d.ts +21 -0
- package/script/src/Changelog.js +24 -3
- package/script/src/Release.d.ts +28 -0
- package/script/src/Release.js +20 -21
- package/script/src/deps.d.ts +2 -0
- package/script/src/deps.js +5 -6
- package/script/src/parser.d.ts +11 -0
- package/script/test/changelog.custom.type.md +2 -3
- package/script/test/changelog.expected.linted.md +3 -4
- package/script/test/changelog.expected.md +3 -4
- package/script/test/changelog.md +3 -4
- package/script/test/empty.expected.md +2 -2
- package/esm/deps/deno.land/std@0.173.0/semver/mod.js +0 -1420
- package/script/deps/deno.land/std@0.173.0/semver/mod.js +0 -1458
- package/types/src/deps.d.ts +0 -1
- /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
- /package/{types → esm}/_dnt.shims.d.ts +0 -0
- /package/{types → esm}/bin.d.ts +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/asserts.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/os.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/flags/mod.d.ts +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_constants.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_interface.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/common.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/glob.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
- /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/separator.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/separator.js +0 -0
- /package/{types → esm}/deps/deno.land/std@0.51.0/fs/eol.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/ini.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/mod.d.ts +0 -0
- /package/{types → esm}/mod.d.ts +0 -0
- /package/{types → esm}/src/Change.d.ts +0 -0
- /package/{types → esm}/src/parser.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
- /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
- /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
- /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
- /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
- /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
- /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](
|
|
7
|
-
and this project adheres to [Semantic Versioning](
|
|
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](
|
|
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.
|
|
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.
|
|
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
|
-
|
|
85
|
-
|
|
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`
|
|
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
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.
|
|
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.
|
|
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", "
|
|
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,
|
|
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,
|
|
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
|
|
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`.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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,
|
|
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
|
|
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)
|
|
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)
|
|
64
|
-
const trailingSeparator = path.charCodeAt(path.length - 1)
|
|
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)
|
|
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)
|
|
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)
|
|
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)
|
|
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)
|
|
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
|
|
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)
|
|
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)
|
|
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
|
|
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
|
|
212
|
+
let matchedNonSeparator = false;
|
|
215
213
|
for (let i = path.length - 1; i >= 1; --i) {
|
|
216
|
-
if (path.charCodeAt(i)
|
|
217
|
-
if (
|
|
214
|
+
if (isPosixPathSeparator(path.charCodeAt(i))) {
|
|
215
|
+
if (matchedNonSeparator) {
|
|
218
216
|
end = i;
|
|
219
217
|
break;
|
|
220
218
|
}
|
|
221
219
|
}
|
|
222
220
|
else {
|
|
223
|
-
|
|
224
|
-
matchedSlash = false;
|
|
221
|
+
matchedNonSeparator = true;
|
|
225
222
|
}
|
|
226
223
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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`.
|
|
235
|
-
*
|
|
236
|
-
*
|
|
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,
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
|
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)
|
|
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
|
|
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
|
|
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`.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
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,
|
|
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
|