Skip to content

Commit

Permalink
feat!: set delimiter to ; in windows (#176)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pooya@pi0.io>
  • Loading branch information
malezjaa and pi0 authored Dec 30, 2024
1 parent 4bcf68f commit 43241f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
const _EXTNAME_RE = /.(\.[^./]+)$/;
const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;

// 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) {
Expand Down
6 changes: 4 additions & 2 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,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 /", () => {
Expand Down

0 comments on commit 43241f6

Please sign in to comment.