@travetto/manifest 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/path.ts +31 -13
package/package.json
CHANGED
package/src/path.ts
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type * as pathMod from 'path';
|
|
2
|
+
import { extname, dirname, basename, resolve, join } from 'path/posix';
|
|
3
|
+
import { sep, resolve as nativeResolve, join as nativeJoin } from 'path';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Converts a given file name by replace all slashes, with forward slashes
|
|
7
|
+
*/
|
|
8
|
+
const toPosix = (file: string): string => file.replaceAll('\\', '/');
|
|
9
|
+
/**
|
|
10
|
+
* Converts a given file name by replace all slashes, with platform dependent path separators
|
|
11
|
+
*/
|
|
12
|
+
const toNative = (file: string): string => file.replaceAll('/', sep);
|
|
5
13
|
|
|
6
|
-
const cwd = (): string =>
|
|
14
|
+
const cwd = (): string => toPosix(process.cwd());
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
type PathModType =
|
|
17
|
+
{ toPosix: typeof toPosix, toNative: typeof toNative } &
|
|
18
|
+
Pick<typeof pathMod, 'basename' | 'dirname' | 'extname' | 'join' | 'resolve'> &
|
|
19
|
+
Pick<typeof process, 'cwd'>;
|
|
20
|
+
|
|
21
|
+
export const path: PathModType = {
|
|
9
22
|
cwd,
|
|
10
|
-
toPosix
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
23
|
+
toPosix,
|
|
24
|
+
toNative,
|
|
25
|
+
basename: (file, suffix) => basename(toPosix(file), suffix),
|
|
26
|
+
extname: file => extname(toPosix(file)),
|
|
27
|
+
dirname: file => dirname(toPosix(file)),
|
|
28
|
+
resolve: (...args) => resolve(cwd(), ...args.map(toPosix)),
|
|
29
|
+
join: (...args) => join(...args.map(toPosix)),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (process.platform === 'win32') {
|
|
33
|
+
path.resolve = (...args: string[]): string => toPosix(nativeResolve(cwd(), ...args.map(toPosix)));
|
|
34
|
+
path.join = (root: string, ...args: string[]): string => toPosix(nativeJoin(toPosix(root), ...args.map(toPosix)));
|
|
35
|
+
}
|