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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Ported from https://github.com/browserify/path-browserify/
|
|
5
5
|
// This module is browser compatible.
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.encodeWhitespace = exports._format = exports.normalizeString = exports.isWindowsDeviceRoot = exports.isPathSeparator = exports.isPosixPathSeparator = exports.assertPath = void 0;
|
|
7
|
+
exports.stripSuffix = exports.stripTrailingSeparators = exports.lastPathSegment = exports.encodeWhitespace = exports._format = exports.normalizeString = exports.isWindowsDeviceRoot = exports.isPathSeparator = exports.isPosixPathSeparator = exports.assertPath = void 0;
|
|
8
8
|
const _constants_js_1 = require("./_constants.js");
|
|
9
9
|
function assertPath(path) {
|
|
10
10
|
if (typeof path !== "string") {
|
|
@@ -104,6 +104,8 @@ function _format(sep, pathObject) {
|
|
|
104
104
|
(pathObject.name || "") + (pathObject.ext || "");
|
|
105
105
|
if (!dir)
|
|
106
106
|
return base;
|
|
107
|
+
if (base === sep)
|
|
108
|
+
return dir;
|
|
107
109
|
if (dir === pathObject.root)
|
|
108
110
|
return dir + base;
|
|
109
111
|
return dir + sep + base;
|
|
@@ -123,3 +125,50 @@ function encodeWhitespace(string) {
|
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
127
|
exports.encodeWhitespace = encodeWhitespace;
|
|
128
|
+
function lastPathSegment(path, isSep, start = 0) {
|
|
129
|
+
let matchedNonSeparator = false;
|
|
130
|
+
let end = path.length;
|
|
131
|
+
for (let i = path.length - 1; i >= start; --i) {
|
|
132
|
+
if (isSep(path.charCodeAt(i))) {
|
|
133
|
+
if (matchedNonSeparator) {
|
|
134
|
+
start = i + 1;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (!matchedNonSeparator) {
|
|
139
|
+
matchedNonSeparator = true;
|
|
140
|
+
end = i + 1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return path.slice(start, end);
|
|
144
|
+
}
|
|
145
|
+
exports.lastPathSegment = lastPathSegment;
|
|
146
|
+
function stripTrailingSeparators(segment, isSep) {
|
|
147
|
+
if (segment.length <= 1) {
|
|
148
|
+
return segment;
|
|
149
|
+
}
|
|
150
|
+
let end = segment.length;
|
|
151
|
+
for (let i = segment.length - 1; i > 0; i--) {
|
|
152
|
+
if (isSep(segment.charCodeAt(i))) {
|
|
153
|
+
end = i;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return segment.slice(0, end);
|
|
160
|
+
}
|
|
161
|
+
exports.stripTrailingSeparators = stripTrailingSeparators;
|
|
162
|
+
function stripSuffix(name, suffix) {
|
|
163
|
+
if (suffix.length >= name.length) {
|
|
164
|
+
return name;
|
|
165
|
+
}
|
|
166
|
+
const lenDiff = name.length - suffix.length;
|
|
167
|
+
for (let i = suffix.length - 1; i >= 0; --i) {
|
|
168
|
+
if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
|
|
169
|
+
return name;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return name.slice(0, -suffix.length);
|
|
173
|
+
}
|
|
174
|
+
exports.stripSuffix = stripSuffix;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Determines the common path from a set of paths, using an optional separator,
|
|
2
|
+
* which defaults to the OS default separator.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { common } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
|
6
|
+
* const p = common([
|
|
7
|
+
* "./deno/std/path/mod.ts",
|
|
8
|
+
* "./deno/std/fs/mod.ts",
|
|
9
|
+
* ]);
|
|
10
|
+
* console.log(p); // "./deno/std/"
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function common(paths: string[], sep?: string): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { OSType } from "../_util/os.js";
|
|
2
|
+
export interface GlobOptions {
|
|
3
|
+
/** Extended glob syntax.
|
|
4
|
+
* See https://www.linuxjournal.com/content/bash-extended-globbing.
|
|
5
|
+
*
|
|
6
|
+
* @default {true}
|
|
7
|
+
*/
|
|
8
|
+
extended?: boolean;
|
|
9
|
+
/** Globstar syntax.
|
|
10
|
+
* See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
|
|
11
|
+
* If false, `**` is treated like `*`.
|
|
12
|
+
*
|
|
13
|
+
* @default {true}
|
|
14
|
+
*/
|
|
15
|
+
globstar?: boolean;
|
|
16
|
+
/** Whether globstar should be case-insensitive. */
|
|
17
|
+
caseInsensitive?: boolean;
|
|
18
|
+
/** Operating system. Defaults to the native OS. */
|
|
19
|
+
os?: OSType;
|
|
20
|
+
}
|
|
21
|
+
export type GlobToRegExpOptions = GlobOptions;
|
|
22
|
+
/** Convert a glob string to a regular expression.
|
|
23
|
+
*
|
|
24
|
+
* Tries to match bash glob expansion as closely as possible.
|
|
25
|
+
*
|
|
26
|
+
* Basic glob syntax:
|
|
27
|
+
* - `*` - Matches everything without leaving the path segment.
|
|
28
|
+
* - `?` - Matches any single character.
|
|
29
|
+
* - `{foo,bar}` - Matches `foo` or `bar`.
|
|
30
|
+
* - `[abcd]` - Matches `a`, `b`, `c` or `d`.
|
|
31
|
+
* - `[a-d]` - Matches `a`, `b`, `c` or `d`.
|
|
32
|
+
* - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
|
|
33
|
+
* - `[[:<class>:]]` - Matches any character belonging to `<class>`.
|
|
34
|
+
* - `[[:alnum:]]` - Matches any digit or letter.
|
|
35
|
+
* - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
|
|
36
|
+
* - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
|
|
37
|
+
* for a complete list of supported character classes.
|
|
38
|
+
* - `\` - Escapes the next character for an `os` other than `"windows"`.
|
|
39
|
+
* - \` - Escapes the next character for `os` set to `"windows"`.
|
|
40
|
+
* - `/` - Path separator.
|
|
41
|
+
* - `\` - Additional path separator only for `os` set to `"windows"`.
|
|
42
|
+
*
|
|
43
|
+
* Extended syntax:
|
|
44
|
+
* - Requires `{ extended: true }`.
|
|
45
|
+
* - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
|
|
46
|
+
* - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
|
|
47
|
+
* - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
|
|
48
|
+
* - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
|
|
49
|
+
* - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
|
|
50
|
+
* - See https://www.linuxjournal.com/content/bash-extended-globbing.
|
|
51
|
+
*
|
|
52
|
+
* Globstar syntax:
|
|
53
|
+
* - Requires `{ globstar: true }`.
|
|
54
|
+
* - `**` - Matches any number of any path segments.
|
|
55
|
+
* - Must comprise its entire path segment in the provided glob.
|
|
56
|
+
* - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
|
|
57
|
+
*
|
|
58
|
+
* Note the following properties:
|
|
59
|
+
* - The generated `RegExp` is anchored at both start and end.
|
|
60
|
+
* - Repeating and trailing separators are tolerated. Trailing separators in the
|
|
61
|
+
* provided glob have no meaning and are discarded.
|
|
62
|
+
* - Absolute globs will only match absolute paths, etc.
|
|
63
|
+
* - Empty globs will match nothing.
|
|
64
|
+
* - Any special glob syntax must be contained to one path segment. For example,
|
|
65
|
+
* `?(foo|bar/baz)` is invalid. The separator will take precedence and the
|
|
66
|
+
* first segment ends with an unclosed group.
|
|
67
|
+
* - If a path segment ends with unclosed groups or a dangling escape prefix, a
|
|
68
|
+
* parse error has occurred. Every character for that segment is taken
|
|
69
|
+
* literally in this event.
|
|
70
|
+
*
|
|
71
|
+
* Limitations:
|
|
72
|
+
* - A negative group like `!(foo|bar)` will wrongly be converted to a negative
|
|
73
|
+
* look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
|
|
74
|
+
* fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
|
|
75
|
+
* `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
|
|
76
|
+
* the group occurs not nested at the end of the segment. */
|
|
77
|
+
export declare function globToRegExp(glob: string, { extended, globstar: globstarOption, os, caseInsensitive, }?: GlobToRegExpOptions): RegExp;
|
|
78
|
+
/** Test whether the given string is a glob */
|
|
79
|
+
export declare function isGlob(str: string): boolean;
|
|
80
|
+
/** Like normalize(), but doesn't collapse "**\/.." when `globstar` is true. */
|
|
81
|
+
export declare function normalizeGlob(glob: string, { globstar }?: GlobOptions): string;
|
|
82
|
+
/** Like join(), but doesn't collapse "**\/.." when `globstar` is true. */
|
|
83
|
+
export declare function joinGlobs(globs: string[], { extended, globstar }?: GlobOptions): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _win32 from "./win32.js";
|
|
2
|
+
import * as _posix from "./posix.js";
|
|
3
|
+
export declare const win32: typeof _win32;
|
|
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, 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;
|
|
8
|
+
export * from "./common.js";
|
|
9
|
+
export { SEP, SEP_PATTERN } from "./separator.js";
|
|
10
|
+
export * from "./_interface.js";
|
|
11
|
+
export * from "./glob.js";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
// Copyright the Browserify authors. MIT License.
|
|
4
4
|
// Ported mostly from https://github.com/browserify/path-browserify/
|
|
5
|
+
// This module is browser compatible.
|
|
5
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
7
|
if (k2 === undefined) k2 = k;
|
|
7
8
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -29,7 +30,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
29
30
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
31
|
};
|
|
31
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.SEP_PATTERN = exports.SEP = exports.
|
|
33
|
+
exports.SEP_PATTERN = exports.SEP = exports.sep = exports.toNamespacedPath = exports.toFileUrl = exports.resolve = exports.relative = exports.parse = exports.normalize = exports.join = exports.isAbsolute = exports.fromFileUrl = exports.format = exports.extname = exports.dirname = exports.delimiter = exports.basename = exports.posix = exports.win32 = void 0;
|
|
33
34
|
/**
|
|
34
35
|
* Utilities for working with OS-specific file paths.
|
|
35
36
|
*
|
|
@@ -54,7 +55,9 @@ const _posix = __importStar(require("./posix.js"));
|
|
|
54
55
|
const path = os_js_1.isWindows ? _win32 : _posix;
|
|
55
56
|
exports.win32 = _win32;
|
|
56
57
|
exports.posix = _posix;
|
|
57
|
-
exports.basename = path.basename, exports.delimiter = path.delimiter, exports.dirname = path.dirname, exports.extname = path.extname, exports.format = path.format, exports.fromFileUrl = path.fromFileUrl, exports.isAbsolute = path.isAbsolute, exports.join = path.join, exports.normalize = path.normalize, exports.parse = path.parse, exports.relative = path.relative, exports.resolve = path.resolve, exports.
|
|
58
|
+
exports.basename = path.basename, exports.delimiter = path.delimiter, exports.dirname = path.dirname, exports.extname = path.extname, exports.format = path.format, exports.fromFileUrl = path.fromFileUrl, exports.isAbsolute = path.isAbsolute, exports.join = path.join, exports.normalize = path.normalize, exports.parse = path.parse, exports.relative = path.relative, exports.resolve = path.resolve, exports.toFileUrl = path.toFileUrl, exports.toNamespacedPath = path.toNamespacedPath;
|
|
59
|
+
/** @deprecated (will be removed after 0.188.0) Use SEP intead. */
|
|
60
|
+
exports.sep = path.sep;
|
|
58
61
|
__exportStar(require("./common.js"), exports);
|
|
59
62
|
var separator_js_1 = require("./separator.js");
|
|
60
63
|
Object.defineProperty(exports, "SEP", { enumerable: true, get: function () { return separator_js_1.SEP; } });
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { FormatInputPathObject, ParsedPath } from "./_interface.js";
|
|
3
|
+
export declare const sep = "/";
|
|
4
|
+
export declare const delimiter = ":";
|
|
5
|
+
/**
|
|
6
|
+
* Resolves `pathSegments` into an absolute path.
|
|
7
|
+
* @param pathSegments an array of path segments
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolve(...pathSegments: string[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize the `path`, resolving `'..'` and `'.'` segments.
|
|
12
|
+
* Note that resolving these segments does not necessarily mean that all will be eliminated.
|
|
13
|
+
* A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
|
|
14
|
+
* @param path to be normalized
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalize(path: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Verifies whether provided path is absolute
|
|
19
|
+
* @param path to be verified as absolute
|
|
20
|
+
*/
|
|
21
|
+
export declare function isAbsolute(path: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Join all given a sequence of `paths`,then normalizes the resulting path.
|
|
24
|
+
* @param paths to be joined and normalized
|
|
25
|
+
*/
|
|
26
|
+
export declare function join(...paths: string[]): string;
|
|
27
|
+
/**
|
|
28
|
+
* Return the relative path from `from` to `to` based on current working directory.
|
|
29
|
+
* @param from path in current working directory
|
|
30
|
+
* @param to path in current working directory
|
|
31
|
+
*/
|
|
32
|
+
export declare function relative(from: string, to: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves path to a namespace path
|
|
35
|
+
* @param path to resolve to namespace
|
|
36
|
+
*/
|
|
37
|
+
export declare function toNamespacedPath(path: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Return the directory path of a `path`.
|
|
40
|
+
* @param path - path to extract the directory from.
|
|
41
|
+
*/
|
|
42
|
+
export declare function dirname(path: string): string;
|
|
43
|
+
/**
|
|
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.
|
|
49
|
+
*/
|
|
50
|
+
export declare function basename(path: string, suffix?: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Return the extension of the `path` with leading period.
|
|
53
|
+
* @param path with extension
|
|
54
|
+
* @returns extension (ex. for `file.ts` returns `.ts`)
|
|
55
|
+
*/
|
|
56
|
+
export declare function extname(path: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Generate a path from `FormatInputPathObject` object.
|
|
59
|
+
* @param pathObject with path
|
|
60
|
+
*/
|
|
61
|
+
export declare function format(pathObject: FormatInputPathObject): string;
|
|
62
|
+
/**
|
|
63
|
+
* Return a `ParsedPath` object of the `path`.
|
|
64
|
+
* @param path to process
|
|
65
|
+
*/
|
|
66
|
+
export declare function parse(path: string): ParsedPath;
|
|
67
|
+
/**
|
|
68
|
+
* Converts a file URL to a path string.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
|
|
72
|
+
* fromFileUrl("file:///home/foo"); // "/home/foo"
|
|
73
|
+
* ```
|
|
74
|
+
* @param url of a file URL
|
|
75
|
+
*/
|
|
76
|
+
export declare function fromFileUrl(url: string | URL): string;
|
|
77
|
+
/**
|
|
78
|
+
* Converts a path string to a file URL.
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
|
|
82
|
+
* toFileUrl("/home/foo"); // new URL("file:///home/foo")
|
|
83
|
+
* ```
|
|
84
|
+
* @param path to convert to file URL
|
|
85
|
+
*/
|
|
86
|
+
export declare function toFileUrl(path: string): URL;
|
|
@@ -59,7 +59,7 @@ function resolve(...pathSegments) {
|
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
61
|
resolvedPath = `${path}/${resolvedPath}`;
|
|
62
|
-
resolvedAbsolute = path.charCodeAt(0)
|
|
62
|
+
resolvedAbsolute = (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
|
|
63
63
|
}
|
|
64
64
|
// At this point the path should be resolved to a full absolute path, but
|
|
65
65
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
@@ -87,8 +87,8 @@ function normalize(path) {
|
|
|
87
87
|
(0, _util_js_1.assertPath)(path);
|
|
88
88
|
if (path.length === 0)
|
|
89
89
|
return ".";
|
|
90
|
-
const isAbsolute = path.charCodeAt(0)
|
|
91
|
-
const trailingSeparator = path.charCodeAt(path.length - 1)
|
|
90
|
+
const isAbsolute = (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
|
|
91
|
+
const trailingSeparator = (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(path.length - 1));
|
|
92
92
|
// Normalize the path
|
|
93
93
|
path = (0, _util_js_1.normalizeString)(path, !isAbsolute, "/", _util_js_1.isPosixPathSeparator);
|
|
94
94
|
if (path.length === 0 && !isAbsolute)
|
|
@@ -106,7 +106,7 @@ exports.normalize = normalize;
|
|
|
106
106
|
*/
|
|
107
107
|
function isAbsolute(path) {
|
|
108
108
|
(0, _util_js_1.assertPath)(path);
|
|
109
|
-
return path.length > 0 && path.charCodeAt(0)
|
|
109
|
+
return path.length > 0 && (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
|
|
110
110
|
}
|
|
111
111
|
exports.isAbsolute = isAbsolute;
|
|
112
112
|
/**
|
|
@@ -150,7 +150,7 @@ function relative(from, to) {
|
|
|
150
150
|
let fromStart = 1;
|
|
151
151
|
const fromEnd = from.length;
|
|
152
152
|
for (; fromStart < fromEnd; ++fromStart) {
|
|
153
|
-
if (from.charCodeAt(fromStart)
|
|
153
|
+
if (!(0, _util_js_1.isPosixPathSeparator)(from.charCodeAt(fromStart)))
|
|
154
154
|
break;
|
|
155
155
|
}
|
|
156
156
|
const fromLen = fromEnd - fromStart;
|
|
@@ -158,7 +158,7 @@ function relative(from, to) {
|
|
|
158
158
|
let toStart = 1;
|
|
159
159
|
const toEnd = to.length;
|
|
160
160
|
for (; toStart < toEnd; ++toStart) {
|
|
161
|
-
if (to.charCodeAt(toStart)
|
|
161
|
+
if (!(0, _util_js_1.isPosixPathSeparator)(to.charCodeAt(toStart)))
|
|
162
162
|
break;
|
|
163
163
|
}
|
|
164
164
|
const toLen = toEnd - toStart;
|
|
@@ -169,7 +169,7 @@ function relative(from, to) {
|
|
|
169
169
|
for (; i <= length; ++i) {
|
|
170
170
|
if (i === length) {
|
|
171
171
|
if (toLen > length) {
|
|
172
|
-
if (to.charCodeAt(toStart + i)
|
|
172
|
+
if ((0, _util_js_1.isPosixPathSeparator)(to.charCodeAt(toStart + i))) {
|
|
173
173
|
// We get here if `from` is the exact base path for `to`.
|
|
174
174
|
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
175
175
|
return to.slice(toStart + i + 1);
|
|
@@ -181,7 +181,7 @@ function relative(from, to) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
else if (fromLen > length) {
|
|
184
|
-
if (from.charCodeAt(fromStart + i)
|
|
184
|
+
if ((0, _util_js_1.isPosixPathSeparator)(from.charCodeAt(fromStart + i))) {
|
|
185
185
|
// We get here if `to` is the exact base path for `from`.
|
|
186
186
|
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
187
187
|
lastCommonSep = i;
|
|
@@ -198,14 +198,14 @@ function relative(from, to) {
|
|
|
198
198
|
const toCode = to.charCodeAt(toStart + i);
|
|
199
199
|
if (fromCode !== toCode)
|
|
200
200
|
break;
|
|
201
|
-
else if (
|
|
201
|
+
else if ((0, _util_js_1.isPosixPathSeparator)(fromCode))
|
|
202
202
|
lastCommonSep = i;
|
|
203
203
|
}
|
|
204
204
|
let out = "";
|
|
205
205
|
// Generate the relative path based on the path difference between `to`
|
|
206
206
|
// and `from`
|
|
207
207
|
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
208
|
-
if (i === fromEnd || from.charCodeAt(i)
|
|
208
|
+
if (i === fromEnd || (0, _util_js_1.isPosixPathSeparator)(from.charCodeAt(i))) {
|
|
209
209
|
if (out.length === 0)
|
|
210
210
|
out += "..";
|
|
211
211
|
else
|
|
@@ -218,7 +218,7 @@ function relative(from, to) {
|
|
|
218
218
|
return out + to.slice(toStart + lastCommonSep);
|
|
219
219
|
else {
|
|
220
220
|
toStart += lastCommonSep;
|
|
221
|
-
if (to.charCodeAt(toStart)
|
|
221
|
+
if ((0, _util_js_1.isPosixPathSeparator)(to.charCodeAt(toStart)))
|
|
222
222
|
++toStart;
|
|
223
223
|
return to.slice(toStart);
|
|
224
224
|
}
|
|
@@ -235,115 +235,54 @@ function toNamespacedPath(path) {
|
|
|
235
235
|
exports.toNamespacedPath = toNamespacedPath;
|
|
236
236
|
/**
|
|
237
237
|
* Return the directory path of a `path`.
|
|
238
|
-
* @param path to
|
|
238
|
+
* @param path - path to extract the directory from.
|
|
239
239
|
*/
|
|
240
240
|
function dirname(path) {
|
|
241
|
-
(0, _util_js_1.assertPath)(path);
|
|
242
241
|
if (path.length === 0)
|
|
243
242
|
return ".";
|
|
244
|
-
const hasRoot = path.charCodeAt(0) === _constants_js_1.CHAR_FORWARD_SLASH;
|
|
245
243
|
let end = -1;
|
|
246
|
-
let
|
|
244
|
+
let matchedNonSeparator = false;
|
|
247
245
|
for (let i = path.length - 1; i >= 1; --i) {
|
|
248
|
-
if (path.charCodeAt(i)
|
|
249
|
-
if (
|
|
246
|
+
if ((0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(i))) {
|
|
247
|
+
if (matchedNonSeparator) {
|
|
250
248
|
end = i;
|
|
251
249
|
break;
|
|
252
250
|
}
|
|
253
251
|
}
|
|
254
252
|
else {
|
|
255
|
-
|
|
256
|
-
matchedSlash = false;
|
|
253
|
+
matchedNonSeparator = true;
|
|
257
254
|
}
|
|
258
255
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
256
|
+
// No matches. Fallback based on provided path:
|
|
257
|
+
//
|
|
258
|
+
// - leading slashes paths
|
|
259
|
+
// "/foo" => "/"
|
|
260
|
+
// "///foo" => "/"
|
|
261
|
+
// - no slash path
|
|
262
|
+
// "foo" => "."
|
|
263
|
+
if (end === -1) {
|
|
264
|
+
return (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0)) ? "/" : ".";
|
|
265
|
+
}
|
|
266
|
+
return (0, _util_js_1.stripTrailingSeparators)(path.slice(0, end), _util_js_1.isPosixPathSeparator);
|
|
264
267
|
}
|
|
265
268
|
exports.dirname = dirname;
|
|
266
269
|
/**
|
|
267
|
-
* Return the last portion of a `path`.
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
+
* Return the last portion of a `path`.
|
|
271
|
+
* Trailing directory separators are ignored, and optional suffix is removed.
|
|
272
|
+
*
|
|
273
|
+
* @param path - path to extract the name from.
|
|
274
|
+
* @param [suffix] - suffix to remove from extracted name.
|
|
270
275
|
*/
|
|
271
|
-
function basename(path,
|
|
272
|
-
if (ext !== undefined && typeof ext !== "string") {
|
|
273
|
-
throw new TypeError('"ext" argument must be a string');
|
|
274
|
-
}
|
|
276
|
+
function basename(path, suffix = "") {
|
|
275
277
|
(0, _util_js_1.assertPath)(path);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
281
|
-
if (ext.length === path.length && ext === path)
|
|
282
|
-
return "";
|
|
283
|
-
let extIdx = ext.length - 1;
|
|
284
|
-
let firstNonSlashEnd = -1;
|
|
285
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
286
|
-
const code = path.charCodeAt(i);
|
|
287
|
-
if ((0, _util_js_1.isPosixPathSeparator)(code)) {
|
|
288
|
-
// If we reached a path separator that was not part of a set of path
|
|
289
|
-
// separators at the end of the string, stop now
|
|
290
|
-
if (!matchedSlash) {
|
|
291
|
-
start = i + 1;
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
if (firstNonSlashEnd === -1) {
|
|
297
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
298
|
-
// path component in case we don't match a whole suffix
|
|
299
|
-
matchedSlash = false;
|
|
300
|
-
firstNonSlashEnd = i + 1;
|
|
301
|
-
end = firstNonSlashEnd;
|
|
302
|
-
}
|
|
303
|
-
if (extIdx >= 0) {
|
|
304
|
-
// Try to match the explicit suffix
|
|
305
|
-
if (code === ext.charCodeAt(extIdx)) {
|
|
306
|
-
if (--extIdx === -1) {
|
|
307
|
-
// We matched whole suffix, so mark this as the end of our path
|
|
308
|
-
// component
|
|
309
|
-
end = i;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
// Suffix character does not match, so bail out early
|
|
314
|
-
// from checking rest of characters
|
|
315
|
-
extIdx = -1;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (end === -1)
|
|
321
|
-
return "";
|
|
322
|
-
if (start === end)
|
|
323
|
-
end = firstNonSlashEnd;
|
|
324
|
-
return path.slice(start, end);
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
328
|
-
if ((0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(i))) {
|
|
329
|
-
// If we reached a path separator that was not part of a set of path
|
|
330
|
-
// separators at the end of the string, stop now
|
|
331
|
-
if (!matchedSlash) {
|
|
332
|
-
start = i + 1;
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
else if (end === -1) {
|
|
337
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
338
|
-
// path component
|
|
339
|
-
matchedSlash = false;
|
|
340
|
-
end = i + 1;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (end === -1)
|
|
344
|
-
return "";
|
|
345
|
-
return path.slice(start, end);
|
|
278
|
+
if (path.length === 0)
|
|
279
|
+
return path;
|
|
280
|
+
if (typeof suffix !== "string") {
|
|
281
|
+
throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);
|
|
346
282
|
}
|
|
283
|
+
const lastSegment = (0, _util_js_1.lastPathSegment)(path, _util_js_1.isPosixPathSeparator);
|
|
284
|
+
const strippedSegment = (0, _util_js_1.stripTrailingSeparators)(lastSegment, _util_js_1.isPosixPathSeparator);
|
|
285
|
+
return suffix ? (0, _util_js_1.stripSuffix)(strippedSegment, suffix) : strippedSegment;
|
|
347
286
|
}
|
|
348
287
|
exports.basename = basename;
|
|
349
288
|
/**
|
|
@@ -362,7 +301,7 @@ function extname(path) {
|
|
|
362
301
|
let preDotState = 0;
|
|
363
302
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
364
303
|
const code = path.charCodeAt(i);
|
|
365
|
-
if (
|
|
304
|
+
if ((0, _util_js_1.isPosixPathSeparator)(code)) {
|
|
366
305
|
// If we reached a path separator that was not part of a set of path
|
|
367
306
|
// separators at the end of the string, stop now
|
|
368
307
|
if (!matchedSlash) {
|
|
@@ -421,7 +360,7 @@ function parse(path) {
|
|
|
421
360
|
const ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
422
361
|
if (path.length === 0)
|
|
423
362
|
return ret;
|
|
424
|
-
const isAbsolute = path.charCodeAt(0)
|
|
363
|
+
const isAbsolute = (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
|
|
425
364
|
let start;
|
|
426
365
|
if (isAbsolute) {
|
|
427
366
|
ret.root = "/";
|
|
@@ -441,7 +380,7 @@ function parse(path) {
|
|
|
441
380
|
// Get non-dir info
|
|
442
381
|
for (; i >= start; --i) {
|
|
443
382
|
const code = path.charCodeAt(i);
|
|
444
|
-
if (
|
|
383
|
+
if ((0, _util_js_1.isPosixPathSeparator)(code)) {
|
|
445
384
|
// If we reached a path separator that was not part of a set of path
|
|
446
385
|
// separators at the end of the string, stop now
|
|
447
386
|
if (!matchedSlash) {
|
|
@@ -483,6 +422,8 @@ function parse(path) {
|
|
|
483
422
|
ret.base = ret.name = path.slice(startPart, end);
|
|
484
423
|
}
|
|
485
424
|
}
|
|
425
|
+
// Fallback to '/' in case there is no basename
|
|
426
|
+
ret.base = ret.base || "/";
|
|
486
427
|
}
|
|
487
428
|
else {
|
|
488
429
|
if (startPart === 0 && isAbsolute) {
|
|
@@ -495,8 +436,9 @@ function parse(path) {
|
|
|
495
436
|
}
|
|
496
437
|
ret.ext = path.slice(startDot, end);
|
|
497
438
|
}
|
|
498
|
-
if (startPart > 0)
|
|
499
|
-
ret.dir = path.slice(0, startPart - 1);
|
|
439
|
+
if (startPart > 0) {
|
|
440
|
+
ret.dir = (0, _util_js_1.stripTrailingSeparators)(path.slice(0, startPart - 1), _util_js_1.isPosixPathSeparator);
|
|
441
|
+
}
|
|
500
442
|
else if (isAbsolute)
|
|
501
443
|
ret.dir = "/";
|
|
502
444
|
return ret;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { FormatInputPathObject, ParsedPath } from "./_interface.js";
|
|
3
|
+
export declare const sep = "\\";
|
|
4
|
+
export declare const delimiter = ";";
|
|
5
|
+
/**
|
|
6
|
+
* Resolves path segments into a `path`
|
|
7
|
+
* @param pathSegments to process to path
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolve(...pathSegments: string[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Normalizes a `path`
|
|
12
|
+
* @param path to normalize
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalize(path: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Verifies whether path is absolute
|
|
17
|
+
* @param path to verify
|
|
18
|
+
*/
|
|
19
|
+
export declare function isAbsolute(path: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Join all given a sequence of `paths`,then normalizes the resulting path.
|
|
22
|
+
* @param paths to be joined and normalized
|
|
23
|
+
*/
|
|
24
|
+
export declare function join(...paths: string[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* It will solve the relative path from `from` to `to`, for instance:
|
|
27
|
+
* from = 'C:\\orandea\\test\\aaa'
|
|
28
|
+
* to = 'C:\\orandea\\impl\\bbb'
|
|
29
|
+
* The output of the function should be: '..\\..\\impl\\bbb'
|
|
30
|
+
* @param from relative path
|
|
31
|
+
* @param to relative path
|
|
32
|
+
*/
|
|
33
|
+
export declare function relative(from: string, to: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves path to a namespace path
|
|
36
|
+
* @param path to resolve to namespace
|
|
37
|
+
*/
|
|
38
|
+
export declare function toNamespacedPath(path: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Return the directory path of a `path`.
|
|
41
|
+
* @param path - path to extract the directory from.
|
|
42
|
+
*/
|
|
43
|
+
export declare function dirname(path: string): string;
|
|
44
|
+
/**
|
|
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.
|
|
50
|
+
*/
|
|
51
|
+
export declare function basename(path: string, suffix?: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Return the extension of the `path` with leading period.
|
|
54
|
+
* @param path with extension
|
|
55
|
+
* @returns extension (ex. for `file.ts` returns `.ts`)
|
|
56
|
+
*/
|
|
57
|
+
export declare function extname(path: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Generate a path from `FormatInputPathObject` object.
|
|
60
|
+
* @param pathObject with path
|
|
61
|
+
*/
|
|
62
|
+
export declare function format(pathObject: FormatInputPathObject): string;
|
|
63
|
+
/**
|
|
64
|
+
* Return a `ParsedPath` object of the `path`.
|
|
65
|
+
* @param path to process
|
|
66
|
+
*/
|
|
67
|
+
export declare function parse(path: string): ParsedPath;
|
|
68
|
+
/**
|
|
69
|
+
* Converts a file URL to a path string.
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/win32.ts";
|
|
73
|
+
* fromFileUrl("file:///home/foo"); // "\\home\\foo"
|
|
74
|
+
* fromFileUrl("file:///C:/Users/foo"); // "C:\\Users\\foo"
|
|
75
|
+
* fromFileUrl("file://localhost/home/foo"); // "\\\\localhost\\home\\foo"
|
|
76
|
+
* ```
|
|
77
|
+
* @param url of a file URL
|
|
78
|
+
*/
|
|
79
|
+
export declare function fromFileUrl(url: string | URL): string;
|
|
80
|
+
/**
|
|
81
|
+
* Converts a path string to a file URL.
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/win32.ts";
|
|
85
|
+
* toFileUrl("\\home\\foo"); // new URL("file:///home/foo")
|
|
86
|
+
* toFileUrl("C:\\Users\\foo"); // new URL("file:///C:/Users/foo")
|
|
87
|
+
* toFileUrl("\\\\127.0.0.1\\home\\foo"); // new URL("file://127.0.0.1/home/foo")
|
|
88
|
+
* ```
|
|
89
|
+
* @param path to convert to file URL
|
|
90
|
+
*/
|
|
91
|
+
export declare function toFileUrl(path: string): URL;
|