Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: set delimiter to ; in windows #176

Merged
merged 7 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 /", () => {
Expand Down
Loading