Inconsistant `path.relative` result
sapphi-red opened this issue · comments
翠 / green commented
import * as pathPosix from 'node:path/posix';
import * as pathWin32 from 'node:path/win32';
import * as pathe from 'pathe';
import * as pathe02 from 'pathe0.2';
const a = process.cwd().replaceAll('\\', '/');
const b = './dist/client/b-scroll.d.ts';
console.log('node:path/posix', pathPosix.relative(a, b));
console.log('node:path/win32', pathWin32.relative(a, b));
console.log('pathe 0.3.2', pathe.relative(a, b));
console.log('pathe 0.2.0', pathe02.relative(a, b));
https://stackblitz.com/edit/node-rdaxjo?file=index.js
Running this on stackblitz outputs
node:path/posix dist/client/b-scroll.d.ts
node:path/win32 dist\client\b-scroll.d.ts
pathe 0.3.2 dist/client/b-scroll.d.ts
pathe 0.2.0 dist/client/b-scroll.d.ts
Running this on Windows outputs (pwd is C:\Users\green\Downloads\node-rdaxjo
)
node:path/posix ../../../../../dist/client/b-scroll.d.ts
node:path/win32 dist\client\b-scroll.d.ts
pathe 0.3.2 ../../../../../C:\Users\green\Downloads\node-rdaxjo/dist/client/b-scroll.d.ts
pathe 0.2.0 ../../../../../dist/client/b-scroll.d.ts
I expect pathe to return dist/client/b-scroll.d.ts
.
Pooya Parsa commented
/cc @danielroe