Skip to content

Commit 6b42a04

Browse files
committed
chore: fix for explorer
1 parent ca26016 commit 6b42a04

File tree

1 file changed

+26
-2
lines changed
  • explorer-v2/build-system/shim

1 file changed

+26
-2
lines changed

explorer-v2/build-system/shim/path.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
11
export default {
22
extname,
33
isAbsolute,
4-
join
4+
join,
5+
resolve,
6+
dirname,
7+
basename
58
};
69

710
export function extname(p) {
811
return /\.[^.]*$/.exec(p)?.[0];
912
}
10-
1113
export function isAbsolute() {
1214
return false;
1315
}
1416
export function join(...args) {
1517
return args.join('/');
1618
}
19+
export function resolve(...args) {
20+
return join(...args);
21+
}
22+
export function parse(s) {
23+
const dir = dirname(s);
24+
const ext = extname(s);
25+
const base = basename(s);
26+
return {
27+
root: '',
28+
dir,
29+
base,
30+
ext,
31+
name: basename(base, ext)
32+
};
33+
}
34+
export function dirname(p) {
35+
return p.split('/').slice(0, -1).join('/') || p;
36+
}
37+
export function basename(p, ext) {
38+
const base = p.split('/').pop() || p;
39+
return base.endsWith(ext) ? base.slice(0, -ext.length) : base;
40+
}

0 commit comments

Comments
 (0)