Skip to content

Commit 4874ae2

Browse files
fabon-fkt3k
andauthored
chore: update standard libraries (#63)
Co-authored-by: Yoshiya Hinosawa <[email protected]>
1 parent 0328797 commit 4874ae2

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
timeout-minutes: 5
1616
steps:
17-
- uses: actions/checkout@v2
18-
- uses: denoland/setup-deno@v1.0.0
17+
- uses: actions/checkout@v4
18+
- uses: denoland/setup-deno@v1
1919
with:
2020
deno-version: v1.x
2121
- run: deno fmt --check

cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
join,
55
NAME,
66
opn,
7-
parseFlags,
7+
parseArgs,
88
red,
99
serveIterable,
1010
VERSION,
@@ -111,7 +111,7 @@ export async function main(cliArgs: string[] = Deno.args): Promise<number> {
111111
"livereload-port": livereloadPort = 35729,
112112
"import-map": importMap,
113113
"config": config,
114-
} = parseFlags(cliArgs, {
114+
} = parseArgs(cliArgs, {
115115
string: [
116116
"log-level",
117117
"out-dir",

deps.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export { createHash } from "https://deno.land/[email protected]/hash/mod.ts";
1+
export { crypto } from "jsr:@std/[email protected]/crypto";
2+
export { parseArgs } from "jsr:@std/[email protected]/parse-args";
23
export {
34
basename,
45
dirname,
@@ -7,18 +8,15 @@ export {
78
relative,
89
resolve,
910
toFileUrl,
10-
} from "https://deno.land/[email protected]/path/mod.ts";
11-
export { parse as parseJsonC } from "https://deno.land/[email protected]/jsonc/mod.ts";
12-
import { join } from "https://deno.land/[email protected]/path/posix.ts";
13-
export { join as posixPathJoin };
11+
} from "jsr:@std/[email protected]";
12+
export { join as posixPathJoin } from "jsr:@std/[email protected]/posix";
13+
export { parse as parseJsonC } from "jsr:@std/[email protected]";
14+
export { ensureDir, exists, walk } from "jsr:@std/[email protected]";
15+
export { red } from "jsr:@std/[email protected]/colors";
16+
export { MuxAsyncIterator } from "jsr:@std/[email protected]";
17+
1418
export { denoPlugins } from "https://deno.land/x/[email protected]/mod.ts";
1519
export { build, stop } from "https://deno.land/x/[email protected]/mod.js";
16-
export { exists } from "https://deno.land/[email protected]/fs/mod.ts";
17-
export { ensureDir } from "https://deno.land/[email protected]/fs/ensure_dir.ts";
18-
export { parse as parseFlags } from "https://deno.land/[email protected]/flags/mod.ts";
19-
export { red } from "https://deno.land/[email protected]/fmt/colors.ts";
20-
export { MuxAsyncIterator } from "https://deno.land/[email protected]/async/mux_async_iterator.ts";
21-
export { walk } from "https://deno.land/[email protected]/fs/walk.ts";
2220

2321
export {
2422
Document,

livereload_server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export function livereloadServer(
9090
const listener = Deno.listen({ port });
9191
const done = (async () => {
9292
for await (const conn of listener) {
93+
// TODO: migrate to Deno.serve
94+
// deno-lint-ignore no-deprecated-deno-api
9395
const httpConn = Deno.serveHttp(conn);
9496
serve(httpConn, eventtarget, port).catch(logger.error);
9597
}

util.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
basename,
3-
createHash,
3+
crypto,
44
Document,
55
Element,
66
fromFileUrl,
@@ -11,9 +11,12 @@ export const decoder = new TextDecoder();
1111
export const encoder = new TextEncoder();
1212

1313
export function md5(data: string | ArrayBuffer): string {
14-
const hash = createHash("md5");
15-
hash.update(data);
16-
return hash.toString();
14+
const digest = crypto.subtle.digestSync(
15+
"MD5",
16+
typeof data === "string" ? new TextEncoder().encode(data) : data,
17+
);
18+
const byteArray = Array.from(new Uint8Array(digest));
19+
return byteArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
1720
}
1821

1922
export async function getDependencies(path: string): Promise<string[]> {

0 commit comments

Comments
 (0)