Skip to content

Commit 4e3db8f

Browse files
committed
Fix docs 修复构建问题
1 parent b7ee5f7 commit 4e3db8f

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

docs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
"build": "ts-node scripts/build.ts"
88
},
99
"license": "GPL-2.0-or-later",
10-
"type": "module",
1110
"devDependencies": {
1211
"@types/fs-extra": "^11.0.2",
1312
"@types/jsdom": "^21.1.3",
13+
"@types/needle": "^3.3.0",
1414
"@types/node": "^20.6.3",
1515
"devok": "workspace:^",
1616
"docsify": "^4.13.1",
1717
"fs-extra": "^11.1.1",
1818
"jsdom": "^22.1.0",
1919
"lethal-build": "^1.3.2",
20-
"node-fetch": "^3.3.2",
20+
"needle": "^3.3.1",
2121
"promise-snake": "^1.3.3"
2222
}
2323
}

docs/scripts/build.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import fse from 'fs-extra';
88
import * as fsp from 'fs/promises';
99
import { JSDOM } from 'jsdom';
1010
import Initer from 'lethal-build';
11-
import fetch from 'node-fetch';
11+
import needle from 'needle';
1212
import * as path from 'path';
1313
import 'promise-snake';
1414

1515
export const {
1616
comp,
1717
dir,
18-
} = Initer(import.meta.url + '/../..');
18+
} = Initer(__dirname + '/../..');
1919

2020
export async function pipeStream(from: NodeJS.ReadableStream, to: NodeJS.WritableStream) {
2121
await new Promise(res => from.pipe(to).once('close', res));
@@ -32,9 +32,9 @@ export function outFilename(file: string) {
3232
return path.relative(dir, file);
3333
}
3434

35-
export async function curl(url: string) {
36-
const rep = await fetch(url, { protocol: 'http:' });
37-
if (!rep.ok) throw new Error(`Failed to fetch ${url}`);
35+
export async function curl(url: string): Promise<NodeJS.ReadableStream> {
36+
const rep = await needle('get', url, { protocol: 'https:' });
37+
if (rep.errored) throw new Error(`Failed to fetch ${url}`);
3838
console.log(`Fetched ${url}`);
3939
return rep;
4040
}
@@ -51,7 +51,7 @@ export interface DownloadCfg {
5151
export async function download(url: string, file: string, { force = false, tryGet = false }: DownloadCfg = {}) {
5252
if (!force && await fse.exists(file)) return console.log(`Already find ${outFilename(file)}`);
5353
try {
54-
await writeFile((await curl(url)).body, file);
54+
await writeFile(await curl(url), file);
5555
}
5656
catch (err) {
5757
if (!tryGet) throw err;

docs/tsconfig.json

-9
This file was deleted.

0 commit comments

Comments
 (0)