Skip to content

Wrong delimiter for windows #175

@malezjaa

Description

@malezjaa

Environment

node: v21.7.3, bun: 1.1.16, pathe: ^1.1.2

Reproduction

import { delimiter } from 'pathe';

const buildPath = (projectPath = process.cwd(), env: Record<string, any>) => {
  const PATH = Object.keys(env)
    .filter((p) => /^path$/i.test(p) && env[p])
    .map((p) => env[p].split(path.delimiter))
    .reduce(
      (set, p) => [
        ...set,
        ...p.filter((concatted: any) => !set.includes(concatted)),
      ],
      [],
    )
    .join(path.delimiter);

  const pathArr = [];

  let p = projectPath;
  let pp;

  do {
    pathArr.push(resolve(p, 'node_modules', '.bin'));
    pp = p;
    p = dirname(p);
  } while (p !== pp);

  pathArr.push(nodeGypPath, PATH);

  const pathVal = pathArr.join(path.delimiter);

  for (const key of Object.keys(env)) {
    if (/^path$/i.test(key)) {
      env[key] = pathVal;
    }
  }

  return env;
};

Describe the bug

The delimiter in the package is designed for macOS and Linux (using a colon ':'), but it doesn't work on Windows, which uses a semicolon ';'.

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions