Skip to content

Commit bb4830d

Browse files
committed
feat: add path methods
1 parent 269ba69 commit bb4830d

File tree

4 files changed

+126
-11
lines changed

4 files changed

+126
-11
lines changed

deps.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
export { join } from "https://deno.land/[email protected]/path/mod.ts";
1+
export {
2+
basename,
3+
dirname,
4+
extname,
5+
fromFileUrl,
6+
isAbsolute,
7+
join,
8+
normalize,
9+
relative,
10+
resolve,
11+
SEP,
12+
SEP_PATTERN,
13+
toFileUrl,
14+
toNamespacedPath,
15+
} from "https://deno.land/[email protected]/path/mod.ts";
216
export { colors } from "https://deno.land/x/[email protected]/ansi/colors.ts";
317
export {
418
iter,
@@ -7,12 +21,12 @@ export {
721
readAllSync,
822
writeAll,
923
writeAllSync,
10-
} from "https://deno.land/std@0.95.0/io/util.ts";
11-
export { Buffer } from "https://deno.land/std@0.95.0/io/buffer.ts";
12-
export { readLines } from "https://deno.land/std@0.95.0/io/bufio.ts";
24+
} from "https://deno.land/std@0.93.0/io/util.ts";
25+
export { Buffer } from "https://deno.land/std@0.93.0/io/buffer.ts";
26+
export { readLines } from "https://deno.land/std@0.93.0/io/bufio.ts";
1327
export { default as escapeStr } from "https://esm.sh/[email protected]";
14-
export { parse as parseFlags } from "https://deno.land/std@0.95.0/flags/mod.ts";
28+
export { parse as parseFlags } from "https://deno.land/std@0.93.0/flags/mod.ts";
1529
export type {
1630
ArgParsingOptions,
1731
Args,
18-
} from "https://deno.land/std@0.95.0/flags/mod.ts";
32+
} from "https://deno.land/std@0.93.0/flags/mod.ts";

dzx.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,62 @@
11
/// <reference path="./types.d.ts" />
22

3-
import { join } from "./deps.ts";
43
import { error } from "./src/_utils.ts";
54
import {
65
$,
6+
basename,
77
Buffer,
88
cd,
9+
dirname,
10+
extname,
11+
fromFileUrl,
12+
isAbsolute,
913
iter,
1014
iterSync,
15+
join,
16+
normalize,
1117
parseFlags,
1218
quote,
1319
readAll,
1420
readAllSync,
1521
readLines,
22+
relative,
23+
resolve,
24+
toFileUrl,
25+
toNamespacedPath,
1626
writeAll,
1727
writeAllSync,
1828
} from "./mod.ts";
1929

30+
// dzx
2031
window.$ = $;
21-
window.Buffer = Buffer;
2232
window.cd = cd;
33+
34+
// std/io
35+
window.Buffer = Buffer;
2336
window.iter = iter;
2437
window.iterSync = iterSync;
25-
window.parseFlags = parseFlags;
2638
window.quote = quote;
2739
window.readAll = readAll;
2840
window.readAllSync = readAllSync;
2941
window.readLines = readLines;
3042
window.writeAll = writeAll;
3143
window.writeAllSync = writeAllSync;
3244

45+
// std/path
46+
window.basename = basename;
47+
window.dirname = dirname;
48+
window.extname = extname;
49+
window.fromFileUrl = fromFileUrl;
50+
window.isAbsolute = isAbsolute;
51+
window.join = join;
52+
window.normalize = normalize;
53+
window.relative = relative;
54+
window.resolve = resolve;
55+
window.toFileUrl = toFileUrl;
56+
window.toNamespacedPath = toNamespacedPath;
57+
58+
window.parseFlags = parseFlags;
59+
3360
const script: string | undefined = Deno.args[0];
3461

3562
try {

mod.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
import {
2+
basename,
23
Buffer,
34
colors,
5+
dirname,
46
escapeStr,
7+
extname,
8+
fromFileUrl,
9+
isAbsolute,
510
iter,
611
iterSync,
12+
join,
13+
normalize,
714
readAll,
815
readAllSync,
916
readLines,
17+
relative,
18+
resolve,
19+
toFileUrl,
20+
toNamespacedPath,
1021
writeAll,
1122
writeAllSync,
1223
} from "./deps.ts";
@@ -35,15 +46,26 @@ $.quote = escapeStr;
3546
$.throwErors = false;
3647

3748
export {
49+
basename,
3850
Buffer,
3951
cd,
52+
dirname,
53+
extname,
54+
fromFileUrl,
55+
isAbsolute,
4056
iter,
4157
iterSync,
58+
join,
59+
normalize,
4260
parseFlags,
4361
quote,
4462
readAll,
4563
readAllSync,
4664
readLines,
65+
relative,
66+
resolve,
67+
toFileUrl,
68+
toNamespacedPath,
4769
writeAll,
4870
writeAllSync,
4971
};

types.d.ts

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,91 @@ import type {
77
import type {
88
ArgParsingOptions as _ArgParsingOptions,
99
Args as _Args,
10+
basename as _basename,
11+
Buffer as _Buffer,
12+
dirname as _dirname,
13+
extname as _extname,
14+
fromFileUrl as _fromFileUrl,
15+
isAbsolute as _isAbsolute,
1016
iter as _iter,
1117
iterSync as _iterSync,
18+
join as _join,
19+
normalize as _normalize,
1220
readAll as _readAll,
1321
readAllSync as _readAllSync,
22+
readLines as _readLines,
23+
relative as _relative,
24+
resolve as _resolve,
25+
toFileUrl as _toFileUrl,
26+
toNamespacedPath as _toNamespacedPath,
1427
writeAll as _writeAll,
1528
writeAllSync as _writeAllSync,
1629
} from "./deps.ts";
1730

1831
declare global {
32+
// dzx
1933
const $: $;
2034
const cd: typeof _cd;
2135
const quote: typeof _quote;
22-
const parseFlags: typeof _parseFlags;
36+
37+
// std/io
38+
const Buffer: typeof _Buffer;
2339
const iter: typeof _iter;
2440
const iterSync: typeof _iterSync;
2541
const readAll: typeof _readAll;
2642
const readAllSync: typeof _readAllSync;
43+
const readLines: typeof _readLines;
2744
const writeAll: typeof _writeAll;
2845
const writeAllSync: typeof _writeAllSync;
2946

47+
// std/path
48+
const basename: typeof _basename;
49+
const dirname: typeof _dirname;
50+
const extname: typeof _extname;
51+
const fromFileUrl: typeof _fromFileUrl;
52+
const isAbsolute: typeof _isAbsolute;
53+
const join: typeof _join;
54+
const normalize: typeof _normalize;
55+
const relative: typeof _relative;
56+
const resolve: typeof _resolve;
57+
const toFileUrl: typeof _toFileUrl;
58+
const toNamespacedPath: typeof _toNamespacedPath;
59+
60+
// std/flags
61+
const parseFlags: typeof _parseFlags;
3062
type ArgParsingOptions = _ArgParsingOptions;
3163
type Args = _Args;
3264

3365
interface Window {
66+
// dzx
3467
$: $;
3568
cd: typeof _cd;
3669
quote: typeof _quote;
37-
parseFlags: typeof _parseFlags;
70+
71+
// std/io
72+
Buffer: typeof _Buffer;
3873
iter: typeof _iter;
3974
iterSync: typeof _iterSync;
4075
readAll: typeof _readAll;
4176
readAllSync: typeof _readAllSync;
77+
readLines: typeof _readLines;
4278
writeAll: typeof _writeAll;
4379
writeAllSync: typeof _writeAllSync;
80+
81+
// std/path
82+
basename: typeof _basename;
83+
dirname: typeof _dirname;
84+
extname: typeof _extname;
85+
fromFileUrl: typeof _fromFileUrl;
86+
isAbsolute: typeof _isAbsolute;
87+
join: typeof _join;
88+
normalize: typeof _normalize;
89+
relative: typeof _relative;
90+
resolve: typeof _resolve;
91+
toFileUrl: typeof _toFileUrl;
92+
toNamespacedPath: typeof _toNamespacedPath;
93+
94+
// std/flags
95+
parseFlags: typeof _parseFlags;
4496
}
4597
}

0 commit comments

Comments
 (0)