keep-a-changelog 2.2.1 → 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.
Files changed (97) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +7 -2
  3. package/esm/_dnt.test_shims.d.ts +5 -0
  4. package/esm/bin.js +8 -3
  5. package/esm/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
  6. package/esm/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
  7. package/esm/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
  8. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +3 -2
  9. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_util.d.ts +3 -0
  10. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +46 -0
  11. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/mod.d.ts +3 -1
  12. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +4 -1
  13. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/posix.d.ts +7 -5
  14. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +50 -108
  15. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/win32.d.ts +7 -5
  16. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +23 -82
  17. package/esm/test/Change.test.d.ts +1 -0
  18. package/esm/test/deps.d.ts +1 -0
  19. package/esm/test/fixture/CustomRelease.d.ts +8 -0
  20. package/esm/test/parser.test.d.ts +1 -0
  21. package/esm/test/test.d.ts +1 -0
  22. package/package.json +5 -12
  23. package/script/_dnt.polyfills.d.ts +11 -0
  24. package/script/_dnt.shims.d.ts +5 -0
  25. package/script/_dnt.test_shims.d.ts +5 -0
  26. package/script/bin.d.ts +2 -0
  27. package/script/bin.js +8 -3
  28. package/script/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
  29. package/script/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
  30. package/script/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
  31. package/script/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
  32. package/script/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
  33. package/script/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
  34. package/script/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
  35. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +4 -3
  36. package/script/deps/deno.land/std@0.189.0/path/_constants.d.ts +39 -0
  37. package/script/deps/deno.land/std@0.189.0/path/_interface.d.ts +26 -0
  38. package/script/deps/deno.land/std@0.189.0/path/_util.d.ts +11 -0
  39. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +50 -1
  40. package/script/deps/deno.land/std@0.189.0/path/common.d.ts +13 -0
  41. package/script/deps/deno.land/std@0.189.0/path/glob.d.ts +83 -0
  42. package/script/deps/deno.land/std@0.189.0/path/mod.d.ts +11 -0
  43. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +5 -2
  44. package/script/deps/deno.land/std@0.189.0/path/posix.d.ts +86 -0
  45. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +48 -106
  46. package/script/deps/deno.land/std@0.189.0/path/separator.d.ts +2 -0
  47. package/script/deps/deno.land/std@0.189.0/path/win32.d.ts +91 -0
  48. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +22 -81
  49. package/script/deps/deno.land/std@0.51.0/fs/eol.d.ts +12 -0
  50. package/script/deps/deno.land/x/ini@v2.1.0/ini.d.ts +53 -0
  51. package/script/deps/deno.land/x/ini@v2.1.0/mod.d.ts +1 -0
  52. package/script/mod.d.ts +6 -0
  53. package/script/src/Change.d.ts +8 -0
  54. package/script/src/Changelog.d.ts +19 -0
  55. package/script/src/Release.d.ts +27 -0
  56. package/script/src/deps.d.ts +1 -0
  57. package/script/src/parser.d.ts +11 -0
  58. package/script/test/Change.test.d.ts +1 -0
  59. package/script/test/deps.d.ts +1 -0
  60. package/script/test/fixture/CustomRelease.d.ts +8 -0
  61. package/script/test/parser.test.d.ts +1 -0
  62. package/script/test/test.d.ts +1 -0
  63. /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
  64. /package/{types → esm}/_dnt.shims.d.ts +0 -0
  65. /package/{types → esm}/bin.d.ts +0 -0
  66. /package/{types → esm}/deps/deno.land/std@0.173.0/semver/mod.d.ts +0 -0
  67. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/asserts.d.ts +0 -0
  68. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
  69. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/os.d.ts +0 -0
  70. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
  71. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/flags/mod.d.ts +0 -0
  72. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_constants.d.ts +0 -0
  73. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
  74. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_interface.d.ts +0 -0
  75. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
  76. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/common.d.ts +0 -0
  77. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
  78. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/glob.d.ts +0 -0
  79. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
  80. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/separator.d.ts +0 -0
  81. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/separator.js +0 -0
  82. /package/{types → esm}/deps/deno.land/std@0.51.0/fs/eol.d.ts +0 -0
  83. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/ini.d.ts +0 -0
  84. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/mod.d.ts +0 -0
  85. /package/{types → esm}/mod.d.ts +0 -0
  86. /package/{types → esm}/src/Change.d.ts +0 -0
  87. /package/{types → esm}/src/Changelog.d.ts +0 -0
  88. /package/{types → esm}/src/Release.d.ts +0 -0
  89. /package/{types → esm}/src/deps.d.ts +0 -0
  90. /package/{types → esm}/src/parser.d.ts +0 -0
  91. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
  92. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
  93. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
  94. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
  95. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
  96. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
  97. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/separator.js +0 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A parsed path object generated by path.parse() or consumed by path.format().
3
+ */
4
+ export interface ParsedPath {
5
+ /**
6
+ * The root of the path such as '/' or 'c:\'
7
+ */
8
+ root: string;
9
+ /**
10
+ * The full directory path such as '/home/user/dir' or 'c:\path\dir'
11
+ */
12
+ dir: string;
13
+ /**
14
+ * The file name including extension (if any) such as 'index.html'
15
+ */
16
+ base: string;
17
+ /**
18
+ * The file extension (if any) such as '.html'
19
+ */
20
+ ext: string;
21
+ /**
22
+ * The file name without extension (if any) such as 'index'
23
+ */
24
+ name: string;
25
+ }
26
+ export type FormatInputPathObject = Partial<ParsedPath>;
@@ -0,0 +1,11 @@
1
+ import type { FormatInputPathObject } from "./_interface.js";
2
+ export declare function assertPath(path: string): void;
3
+ export declare function isPosixPathSeparator(code: number): boolean;
4
+ export declare function isPathSeparator(code: number): boolean;
5
+ export declare function isWindowsDeviceRoot(code: number): boolean;
6
+ export declare function normalizeString(path: string, allowAboveRoot: boolean, separator: string, isPathSeparator: (code: number) => boolean): string;
7
+ export declare function _format(sep: string, pathObject: FormatInputPathObject): string;
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;
@@ -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.toNamespacedPath = exports.toFileUrl = exports.sep = 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
+ 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.sep = path.sep, exports.toFileUrl = path.toFileUrl, exports.toNamespacedPath = path.toNamespacedPath;
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) === _constants_js_1.CHAR_FORWARD_SLASH;
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) === _constants_js_1.CHAR_FORWARD_SLASH;
91
- const trailingSeparator = path.charCodeAt(path.length - 1) === _constants_js_1.CHAR_FORWARD_SLASH;
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) === _constants_js_1.CHAR_FORWARD_SLASH;
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) !== _constants_js_1.CHAR_FORWARD_SLASH)
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) !== _constants_js_1.CHAR_FORWARD_SLASH)
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) === _constants_js_1.CHAR_FORWARD_SLASH) {
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) === _constants_js_1.CHAR_FORWARD_SLASH) {
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 (fromCode === _constants_js_1.CHAR_FORWARD_SLASH)
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) === _constants_js_1.CHAR_FORWARD_SLASH) {
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) === _constants_js_1.CHAR_FORWARD_SLASH)
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 determine the directory path for
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 matchedSlash = true;
244
+ let matchedNonSeparator = false;
247
245
  for (let i = path.length - 1; i >= 1; --i) {
248
- if (path.charCodeAt(i) === _constants_js_1.CHAR_FORWARD_SLASH) {
249
- if (!matchedSlash) {
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
- // We saw the first non-path separator
256
- matchedSlash = false;
253
+ matchedNonSeparator = true;
257
254
  }
258
255
  }
259
- if (end === -1)
260
- return hasRoot ? "/" : ".";
261
- if (hasRoot && end === 1)
262
- return "//";
263
- return path.slice(0, end);
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`. Trailing directory separators are ignored.
268
- * @param path to process
269
- * @param ext of path directory
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, ext = "") {
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
- let start = 0;
277
- let end = -1;
278
- let matchedSlash = true;
279
- let i;
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 (code === _constants_js_1.CHAR_FORWARD_SLASH) {
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) === _constants_js_1.CHAR_FORWARD_SLASH;
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 (code === _constants_js_1.CHAR_FORWARD_SLASH) {
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,2 @@
1
+ export declare const SEP: string;
2
+ export declare const SEP_PATTERN: RegExp;