keep-a-changelog 2.1.0 → 2.3.0
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 +28 -2
- package/README.md +23 -6
- package/esm/_dnt.test_shims.d.ts +5 -0
- package/esm/bin.js +11 -2
- package/esm/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
- package/esm/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
- package/esm/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
- package/esm/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +227 -334
- package/esm/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
- package/esm/deps/deno.land/std@0.189.0/_util/asserts.js +21 -0
- package/esm/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/_util/os.js +3 -2
- package/esm/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/flags/mod.js +146 -36
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_constants.js +1 -0
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_interface.d.ts +1 -1
- package/esm/deps/deno.land/std@0.189.0/path/_interface.js +3 -0
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_util.d.ts +3 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_util.js +47 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/common.js +1 -1
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/glob.d.ts +10 -5
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/glob.js +1 -1
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/mod.d.ts +3 -1
- package/esm/deps/deno.land/std@0.189.0/path/mod.js +35 -0
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/posix.d.ts +15 -9
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/posix.js +58 -112
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/separator.js +1 -1
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/win32.d.ts +13 -9
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/win32.js +30 -87
- package/esm/src/Change.js +15 -15
- package/{types → esm}/src/Changelog.d.ts +1 -0
- package/esm/src/Changelog.js +9 -1
- package/{types → esm}/src/Release.d.ts +1 -0
- package/esm/src/Release.js +10 -0
- package/esm/src/deps.d.ts +1 -0
- package/esm/src/deps.js +1 -1
- package/esm/src/parser.js +19 -3
- package/esm/test/Change.test.d.ts +1 -0
- package/esm/test/changelog.custom.type.md +0 -1
- package/esm/test/changelog.expected.linted.md +208 -0
- package/esm/test/changelog.expected.md +3 -1
- package/esm/test/changelog.md +4 -0
- package/esm/test/deps.d.ts +1 -0
- package/esm/test/empty.expected.md +0 -1
- package/esm/test/fixture/CustomRelease.d.ts +8 -0
- package/esm/test/parser.test.d.ts +1 -0
- package/esm/test/test.d.ts +1 -0
- package/package.json +6 -8
- package/script/_dnt.polyfills.d.ts +11 -0
- package/script/_dnt.shims.d.ts +5 -0
- package/script/_dnt.test_shims.d.ts +5 -0
- package/script/bin.d.ts +2 -0
- package/script/bin.js +11 -2
- package/script/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
- package/script/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
- package/script/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
- package/script/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
- package/script/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +232 -342
- 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/asserts.js +27 -0
- package/script/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/_util/os.js +4 -3
- package/script/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/flags/mod.js +150 -40
- package/script/deps/deno.land/std@0.189.0/path/_constants.d.ts +39 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_constants.js +1 -0
- package/script/deps/deno.land/std@0.189.0/path/_interface.d.ts +26 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_interface.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/_util.d.ts +11 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_util.js +51 -1
- package/script/deps/deno.land/std@0.189.0/path/common.d.ts +13 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/common.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/glob.d.ts +83 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/glob.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/mod.d.ts +11 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/mod.js +23 -2
- package/script/deps/deno.land/std@0.189.0/path/posix.d.ts +86 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/posix.js +56 -110
- package/script/deps/deno.land/std@0.189.0/path/separator.d.ts +2 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/separator.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/win32.d.ts +91 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/win32.js +30 -87
- 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/Change.js +15 -15
- package/script/src/Changelog.d.ts +19 -0
- package/script/src/Changelog.js +9 -1
- package/script/src/Release.d.ts +27 -0
- package/script/src/Release.js +10 -0
- package/script/src/deps.d.ts +1 -0
- package/script/src/deps.js +1 -1
- package/script/src/parser.d.ts +11 -0
- package/script/src/parser.js +19 -3
- package/script/test/Change.test.d.ts +1 -0
- package/script/test/changelog.custom.type.md +0 -1
- package/script/test/changelog.expected.linted.md +208 -0
- package/script/test/changelog.expected.md +3 -1
- package/script/test/changelog.md +4 -0
- package/script/test/deps.d.ts +1 -0
- package/script/test/empty.expected.md +0 -1
- package/script/test/fixture/CustomRelease.d.ts +8 -0
- package/script/test/parser.test.d.ts +1 -0
- package/script/test/test.d.ts +1 -0
- package/esm/deps/deno.land/std@0.120.0/_util/assert.js +0 -13
- package/esm/deps/deno.land/std@0.120.0/path/_interface.js +0 -3
- package/esm/deps/deno.land/std@0.120.0/path/mod.js +0 -14
- package/script/deps/deno.land/std@0.120.0/_util/assert.js +0 -18
- package/types/deps/deno.land/std@0.120.0/_util/assert.d.ts +0 -5
- package/types/deps/deno.land/std@0.120.0/_util/os.d.ts +0 -3
- package/types/deps/deno.land/std@0.120.0/flags/mod.d.ts +0 -50
- package/types/deps/deno.land/x/semver@v1.4.0/mod.d.ts +0 -116
- 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.120.0 → esm/deps/deno.land/std@0.189.0}/path/_constants.d.ts +0 -0
- /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/common.d.ts +0 -0
- /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/separator.d.ts +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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
3
|
// Copyright the Browserify authors. MIT License.
|
|
3
4
|
// Ported from https://github.com/browserify/path-browserify/
|
|
4
5
|
// This module is browser compatible.
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
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;
|
|
7
8
|
const _constants_js_1 = require("./_constants.js");
|
|
8
9
|
function assertPath(path) {
|
|
9
10
|
if (typeof path !== "string") {
|
|
@@ -103,6 +104,8 @@ function _format(sep, pathObject) {
|
|
|
103
104
|
(pathObject.name || "") + (pathObject.ext || "");
|
|
104
105
|
if (!dir)
|
|
105
106
|
return base;
|
|
107
|
+
if (base === sep)
|
|
108
|
+
return dir;
|
|
106
109
|
if (dir === pathObject.root)
|
|
107
110
|
return dir + base;
|
|
108
111
|
return dir + sep + base;
|
|
@@ -122,3 +125,50 @@ function encodeWhitespace(string) {
|
|
|
122
125
|
});
|
|
123
126
|
}
|
|
124
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
// This module is browser compatible.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.common = void 0;
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
// This module is browser compatible.
|
|
4
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
5
|
if (k2 === undefined) k2 = k;
|
|
@@ -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";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
3
|
// Copyright the Browserify authors. MIT License.
|
|
3
4
|
// Ported mostly from https://github.com/browserify/path-browserify/
|
|
4
5
|
// This module is browser compatible.
|
|
@@ -29,14 +30,34 @@ 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;
|
|
34
|
+
/**
|
|
35
|
+
* Utilities for working with OS-specific file paths.
|
|
36
|
+
*
|
|
37
|
+
* Codes in the examples uses POSIX path but it automatically use Windows path
|
|
38
|
+
* on Windows. Use methods under `posix` or `win32` object instead to handle non
|
|
39
|
+
* platform specific path like:
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { posix, win32 } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
|
42
|
+
* const p1 = posix.fromFileUrl("file:///home/foo");
|
|
43
|
+
* const p2 = win32.fromFileUrl("file:///home/foo");
|
|
44
|
+
* console.log(p1); // "/home/foo"
|
|
45
|
+
* console.log(p2); // "\\home\\foo"
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* This module is browser compatible.
|
|
49
|
+
*
|
|
50
|
+
* @module
|
|
51
|
+
*/
|
|
33
52
|
const os_js_1 = require("../_util/os.js");
|
|
34
53
|
const _win32 = __importStar(require("./win32.js"));
|
|
35
54
|
const _posix = __importStar(require("./posix.js"));
|
|
36
55
|
const path = os_js_1.isWindows ? _win32 : _posix;
|
|
37
56
|
exports.win32 = _win32;
|
|
38
57
|
exports.posix = _posix;
|
|
39
|
-
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;
|
|
40
61
|
__exportStar(require("./common.js"), exports);
|
|
41
62
|
var separator_js_1 = require("./separator.js");
|
|
42
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;
|
|
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.toFileUrl = exports.fromFileUrl = exports.parse = exports.format = exports.extname = exports.basename = exports.dirname = exports.toNamespacedPath = exports.relative = exports.join = exports.isAbsolute = exports.normalize = exports.resolve = exports.delimiter = exports.sep = void 0;
|
|
27
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
27
28
|
// Copyright the Browserify authors. MIT License.
|
|
28
29
|
// Ported from https://github.com/browserify/path-browserify/
|
|
29
30
|
// This module is browser compatible.
|
|
@@ -58,7 +59,7 @@ function resolve(...pathSegments) {
|
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
60
61
|
resolvedPath = `${path}/${resolvedPath}`;
|
|
61
|
-
resolvedAbsolute = path.charCodeAt(0)
|
|
62
|
+
resolvedAbsolute = (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
|
|
62
63
|
}
|
|
63
64
|
// At this point the path should be resolved to a full absolute path, but
|
|
64
65
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
@@ -78,14 +79,16 @@ function resolve(...pathSegments) {
|
|
|
78
79
|
exports.resolve = resolve;
|
|
79
80
|
/**
|
|
80
81
|
* Normalize the `path`, resolving `'..'` and `'.'` segments.
|
|
82
|
+
* Note that resolving these segments does not necessarily mean that all will be eliminated.
|
|
83
|
+
* A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
|
|
81
84
|
* @param path to be normalized
|
|
82
85
|
*/
|
|
83
86
|
function normalize(path) {
|
|
84
87
|
(0, _util_js_1.assertPath)(path);
|
|
85
88
|
if (path.length === 0)
|
|
86
89
|
return ".";
|
|
87
|
-
const isAbsolute = path.charCodeAt(0)
|
|
88
|
-
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));
|
|
89
92
|
// Normalize the path
|
|
90
93
|
path = (0, _util_js_1.normalizeString)(path, !isAbsolute, "/", _util_js_1.isPosixPathSeparator);
|
|
91
94
|
if (path.length === 0 && !isAbsolute)
|
|
@@ -103,7 +106,7 @@ exports.normalize = normalize;
|
|
|
103
106
|
*/
|
|
104
107
|
function isAbsolute(path) {
|
|
105
108
|
(0, _util_js_1.assertPath)(path);
|
|
106
|
-
return path.length > 0 && path.charCodeAt(0)
|
|
109
|
+
return path.length > 0 && (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
|
|
107
110
|
}
|
|
108
111
|
exports.isAbsolute = isAbsolute;
|
|
109
112
|
/**
|
|
@@ -147,7 +150,7 @@ function relative(from, to) {
|
|
|
147
150
|
let fromStart = 1;
|
|
148
151
|
const fromEnd = from.length;
|
|
149
152
|
for (; fromStart < fromEnd; ++fromStart) {
|
|
150
|
-
if (from.charCodeAt(fromStart)
|
|
153
|
+
if (!(0, _util_js_1.isPosixPathSeparator)(from.charCodeAt(fromStart)))
|
|
151
154
|
break;
|
|
152
155
|
}
|
|
153
156
|
const fromLen = fromEnd - fromStart;
|
|
@@ -155,7 +158,7 @@ function relative(from, to) {
|
|
|
155
158
|
let toStart = 1;
|
|
156
159
|
const toEnd = to.length;
|
|
157
160
|
for (; toStart < toEnd; ++toStart) {
|
|
158
|
-
if (to.charCodeAt(toStart)
|
|
161
|
+
if (!(0, _util_js_1.isPosixPathSeparator)(to.charCodeAt(toStart)))
|
|
159
162
|
break;
|
|
160
163
|
}
|
|
161
164
|
const toLen = toEnd - toStart;
|
|
@@ -166,7 +169,7 @@ function relative(from, to) {
|
|
|
166
169
|
for (; i <= length; ++i) {
|
|
167
170
|
if (i === length) {
|
|
168
171
|
if (toLen > length) {
|
|
169
|
-
if (to.charCodeAt(toStart + i)
|
|
172
|
+
if ((0, _util_js_1.isPosixPathSeparator)(to.charCodeAt(toStart + i))) {
|
|
170
173
|
// We get here if `from` is the exact base path for `to`.
|
|
171
174
|
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
172
175
|
return to.slice(toStart + i + 1);
|
|
@@ -178,7 +181,7 @@ function relative(from, to) {
|
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
else if (fromLen > length) {
|
|
181
|
-
if (from.charCodeAt(fromStart + i)
|
|
184
|
+
if ((0, _util_js_1.isPosixPathSeparator)(from.charCodeAt(fromStart + i))) {
|
|
182
185
|
// We get here if `to` is the exact base path for `from`.
|
|
183
186
|
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
184
187
|
lastCommonSep = i;
|
|
@@ -195,14 +198,14 @@ function relative(from, to) {
|
|
|
195
198
|
const toCode = to.charCodeAt(toStart + i);
|
|
196
199
|
if (fromCode !== toCode)
|
|
197
200
|
break;
|
|
198
|
-
else if (
|
|
201
|
+
else if ((0, _util_js_1.isPosixPathSeparator)(fromCode))
|
|
199
202
|
lastCommonSep = i;
|
|
200
203
|
}
|
|
201
204
|
let out = "";
|
|
202
205
|
// Generate the relative path based on the path difference between `to`
|
|
203
206
|
// and `from`
|
|
204
207
|
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
205
|
-
if (i === fromEnd || from.charCodeAt(i)
|
|
208
|
+
if (i === fromEnd || (0, _util_js_1.isPosixPathSeparator)(from.charCodeAt(i))) {
|
|
206
209
|
if (out.length === 0)
|
|
207
210
|
out += "..";
|
|
208
211
|
else
|
|
@@ -215,7 +218,7 @@ function relative(from, to) {
|
|
|
215
218
|
return out + to.slice(toStart + lastCommonSep);
|
|
216
219
|
else {
|
|
217
220
|
toStart += lastCommonSep;
|
|
218
|
-
if (to.charCodeAt(toStart)
|
|
221
|
+
if ((0, _util_js_1.isPosixPathSeparator)(to.charCodeAt(toStart)))
|
|
219
222
|
++toStart;
|
|
220
223
|
return to.slice(toStart);
|
|
221
224
|
}
|
|
@@ -231,121 +234,61 @@ function toNamespacedPath(path) {
|
|
|
231
234
|
}
|
|
232
235
|
exports.toNamespacedPath = toNamespacedPath;
|
|
233
236
|
/**
|
|
234
|
-
* Return the directory
|
|
235
|
-
* @param path to
|
|
237
|
+
* Return the directory path of a `path`.
|
|
238
|
+
* @param path - path to extract the directory from.
|
|
236
239
|
*/
|
|
237
240
|
function dirname(path) {
|
|
238
|
-
(0, _util_js_1.assertPath)(path);
|
|
239
241
|
if (path.length === 0)
|
|
240
242
|
return ".";
|
|
241
|
-
const hasRoot = path.charCodeAt(0) === _constants_js_1.CHAR_FORWARD_SLASH;
|
|
242
243
|
let end = -1;
|
|
243
|
-
let
|
|
244
|
+
let matchedNonSeparator = false;
|
|
244
245
|
for (let i = path.length - 1; i >= 1; --i) {
|
|
245
|
-
if (path.charCodeAt(i)
|
|
246
|
-
if (
|
|
246
|
+
if ((0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(i))) {
|
|
247
|
+
if (matchedNonSeparator) {
|
|
247
248
|
end = i;
|
|
248
249
|
break;
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
else {
|
|
252
|
-
|
|
253
|
-
matchedSlash = false;
|
|
253
|
+
matchedNonSeparator = true;
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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);
|
|
261
267
|
}
|
|
262
268
|
exports.dirname = dirname;
|
|
263
269
|
/**
|
|
264
|
-
* Return the last portion of a `path`.
|
|
265
|
-
*
|
|
266
|
-
*
|
|
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.
|
|
267
275
|
*/
|
|
268
|
-
function basename(path,
|
|
269
|
-
if (ext !== undefined && typeof ext !== "string") {
|
|
270
|
-
throw new TypeError('"ext" argument must be a string');
|
|
271
|
-
}
|
|
276
|
+
function basename(path, suffix = "") {
|
|
272
277
|
(0, _util_js_1.assertPath)(path);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
278
|
-
if (ext.length === path.length && ext === path)
|
|
279
|
-
return "";
|
|
280
|
-
let extIdx = ext.length - 1;
|
|
281
|
-
let firstNonSlashEnd = -1;
|
|
282
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
283
|
-
const code = path.charCodeAt(i);
|
|
284
|
-
if (code === _constants_js_1.CHAR_FORWARD_SLASH) {
|
|
285
|
-
// If we reached a path separator that was not part of a set of path
|
|
286
|
-
// separators at the end of the string, stop now
|
|
287
|
-
if (!matchedSlash) {
|
|
288
|
-
start = i + 1;
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
if (firstNonSlashEnd === -1) {
|
|
294
|
-
// We saw the first non-path separator, remember this index in case
|
|
295
|
-
// we need it if the extension ends up not matching
|
|
296
|
-
matchedSlash = false;
|
|
297
|
-
firstNonSlashEnd = i + 1;
|
|
298
|
-
}
|
|
299
|
-
if (extIdx >= 0) {
|
|
300
|
-
// Try to match the explicit extension
|
|
301
|
-
if (code === ext.charCodeAt(extIdx)) {
|
|
302
|
-
if (--extIdx === -1) {
|
|
303
|
-
// We matched the extension, so mark this as the end of our path
|
|
304
|
-
// component
|
|
305
|
-
end = i;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
// Extension does not match, so our result is the entire path
|
|
310
|
-
// component
|
|
311
|
-
extIdx = -1;
|
|
312
|
-
end = firstNonSlashEnd;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if (start === end)
|
|
318
|
-
end = firstNonSlashEnd;
|
|
319
|
-
else if (end === -1)
|
|
320
|
-
end = path.length;
|
|
321
|
-
return path.slice(start, end);
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
325
|
-
if (path.charCodeAt(i) === _constants_js_1.CHAR_FORWARD_SLASH) {
|
|
326
|
-
// If we reached a path separator that was not part of a set of path
|
|
327
|
-
// separators at the end of the string, stop now
|
|
328
|
-
if (!matchedSlash) {
|
|
329
|
-
start = i + 1;
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else if (end === -1) {
|
|
334
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
335
|
-
// path component
|
|
336
|
-
matchedSlash = false;
|
|
337
|
-
end = i + 1;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
if (end === -1)
|
|
341
|
-
return "";
|
|
342
|
-
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)}`);
|
|
343
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;
|
|
344
286
|
}
|
|
345
287
|
exports.basename = basename;
|
|
346
288
|
/**
|
|
347
|
-
* Return the extension of the `path
|
|
289
|
+
* Return the extension of the `path` with leading period.
|
|
348
290
|
* @param path with extension
|
|
291
|
+
* @returns extension (ex. for `file.ts` returns `.ts`)
|
|
349
292
|
*/
|
|
350
293
|
function extname(path) {
|
|
351
294
|
(0, _util_js_1.assertPath)(path);
|
|
@@ -358,7 +301,7 @@ function extname(path) {
|
|
|
358
301
|
let preDotState = 0;
|
|
359
302
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
360
303
|
const code = path.charCodeAt(i);
|
|
361
|
-
if (
|
|
304
|
+
if ((0, _util_js_1.isPosixPathSeparator)(code)) {
|
|
362
305
|
// If we reached a path separator that was not part of a set of path
|
|
363
306
|
// separators at the end of the string, stop now
|
|
364
307
|
if (!matchedSlash) {
|
|
@@ -417,7 +360,7 @@ function parse(path) {
|
|
|
417
360
|
const ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
418
361
|
if (path.length === 0)
|
|
419
362
|
return ret;
|
|
420
|
-
const isAbsolute = path.charCodeAt(0)
|
|
363
|
+
const isAbsolute = (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
|
|
421
364
|
let start;
|
|
422
365
|
if (isAbsolute) {
|
|
423
366
|
ret.root = "/";
|
|
@@ -437,7 +380,7 @@ function parse(path) {
|
|
|
437
380
|
// Get non-dir info
|
|
438
381
|
for (; i >= start; --i) {
|
|
439
382
|
const code = path.charCodeAt(i);
|
|
440
|
-
if (
|
|
383
|
+
if ((0, _util_js_1.isPosixPathSeparator)(code)) {
|
|
441
384
|
// If we reached a path separator that was not part of a set of path
|
|
442
385
|
// separators at the end of the string, stop now
|
|
443
386
|
if (!matchedSlash) {
|
|
@@ -479,6 +422,8 @@ function parse(path) {
|
|
|
479
422
|
ret.base = ret.name = path.slice(startPart, end);
|
|
480
423
|
}
|
|
481
424
|
}
|
|
425
|
+
// Fallback to '/' in case there is no basename
|
|
426
|
+
ret.base = ret.base || "/";
|
|
482
427
|
}
|
|
483
428
|
else {
|
|
484
429
|
if (startPart === 0 && isAbsolute) {
|
|
@@ -491,8 +436,9 @@ function parse(path) {
|
|
|
491
436
|
}
|
|
492
437
|
ret.ext = path.slice(startDot, end);
|
|
493
438
|
}
|
|
494
|
-
if (startPart > 0)
|
|
495
|
-
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
|
+
}
|
|
496
442
|
else if (isAbsolute)
|
|
497
443
|
ret.dir = "/";
|
|
498
444
|
return ret;
|
|
@@ -502,7 +448,7 @@ exports.parse = parse;
|
|
|
502
448
|
* Converts a file URL to a path string.
|
|
503
449
|
*
|
|
504
450
|
* ```ts
|
|
505
|
-
* import { fromFileUrl } from "
|
|
451
|
+
* import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
|
|
506
452
|
* fromFileUrl("file:///home/foo"); // "/home/foo"
|
|
507
453
|
* ```
|
|
508
454
|
* @param url of a file URL
|
|
@@ -519,7 +465,7 @@ exports.fromFileUrl = fromFileUrl;
|
|
|
519
465
|
* Converts a path string to a file URL.
|
|
520
466
|
*
|
|
521
467
|
* ```ts
|
|
522
|
-
* import { toFileUrl } from "
|
|
468
|
+
* import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
|
|
523
469
|
* toFileUrl("/home/foo"); // new URL("file:///home/foo")
|
|
524
470
|
* ```
|
|
525
471
|
* @param path to convert to file URL
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
// This module is browser compatible.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.SEP_PATTERN = exports.SEP = void 0;
|