diff --git a/src/path.ts b/src/path.ts index 591f70e..eea9a71 100644 --- a/src/path.ts +++ b/src/path.ts @@ -16,11 +16,19 @@ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/; const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/; const _EXTNAME_RE = /.(\.[^./]+)$/; -// Force POSIX constants - -export const sep: typeof path.sep = "/"; +/** + * Constant for path separator. + * + * Always equals to `"/"`. + */ +export const sep = "/"; -export const delimiter: typeof path.delimiter = ":"; +/** + * The platform-specific file delimiter. + * + * Equals to `";"` in windows and `":"` in all other platforms. + */ +export const delimiter = globalThis.process?.platform === "win32" ? ";" : ":"; export const normalize: typeof path.normalize = function (path: string) { if (path.length === 0) { diff --git a/test/index.spec.ts b/test/index.spec.ts index b520425..8a52089 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -365,8 +365,10 @@ runTest("toNamespacedPath", toNamespacedPath, { }); describe("constants", () => { - it("delimiter should equal :", () => { - expect(delimiter).to.equal(":"); + it("delimiter", () => { + expect(delimiter).to.equal( + globalThis.process?.platform === "win32" ? ";" : ":", + ); }); it("sep should equal /", () => {