Skip to content

Commit

Permalink
Fix docs 修复构建问题
Browse files Browse the repository at this point in the history
  • Loading branch information
E0SelmY4V committed Jan 21, 2024
1 parent b7ee5f7 commit 4e3db8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"build": "ts-node scripts/build.ts"
},
"license": "GPL-2.0-or-later",
"type": "module",
"devDependencies": {
"@types/fs-extra": "^11.0.2",
"@types/jsdom": "^21.1.3",
"@types/needle": "^3.3.0",
"@types/node": "^20.6.3",
"devok": "workspace:^",
"docsify": "^4.13.1",
"fs-extra": "^11.1.1",
"jsdom": "^22.1.0",
"lethal-build": "^1.3.2",
"node-fetch": "^3.3.2",
"needle": "^3.3.1",
"promise-snake": "^1.3.3"
}
}
12 changes: 6 additions & 6 deletions docs/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import fse from 'fs-extra';
import * as fsp from 'fs/promises';
import { JSDOM } from 'jsdom';
import Initer from 'lethal-build';
import fetch from 'node-fetch';
import needle from 'needle';
import * as path from 'path';
import 'promise-snake';

export const {
comp,
dir,
} = Initer(import.meta.url + '/../..');
} = Initer(__dirname + '/../..');

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

export async function curl(url: string) {
const rep = await fetch(url, { protocol: 'http:' });
if (!rep.ok) throw new Error(`Failed to fetch ${url}`);
export async function curl(url: string): Promise<NodeJS.ReadableStream> {
const rep = await needle('get', url, { protocol: 'https:' });
if (rep.errored) throw new Error(`Failed to fetch ${url}`);
console.log(`Fetched ${url}`);
return rep;
}
Expand All @@ -51,7 +51,7 @@ export interface DownloadCfg {
export async function download(url: string, file: string, { force = false, tryGet = false }: DownloadCfg = {}) {
if (!force && await fse.exists(file)) return console.log(`Already find ${outFilename(file)}`);
try {
await writeFile((await curl(url)).body, file);
await writeFile(await curl(url), file);
}
catch (err) {
if (!tryGet) throw err;
Expand Down
9 changes: 0 additions & 9 deletions docs/tsconfig.json

This file was deleted.

0 comments on commit 4e3db8f

Please sign in to comment.