🐛 #80 修复 win depd bug

This commit is contained in:
muwoo
2022-01-13 18:38:44 +08:00
parent e5ff219685
commit 1e73ab5ee6
5 changed files with 35 additions and 38 deletions

View File

@@ -3,7 +3,6 @@ import {
AdapterInfo,
} from "@/core/plugin-handler/types";
import fs from "fs-extra";
import search, { Result } from "libnpmsearch";
import path from "path";
import got from "got";
import fixPath from "fix-path";
@@ -90,30 +89,6 @@ class AdapterHandler {
await this.execCommand(installCmd, adapters);
}
/**
* 从 npm 搜索插件
* 传入 streamFunc 可以流式处理
* @param {string} adapter 插件名称
* @param {(data: Result) => void} [streamFunc] 流式处理钩子
* @memberof AdapterHandler
*/
async search(adapter: string, streamFunc?: (data: Result) => void) {
return await new Promise<Result[]>((resolve, reject) => {
const result: Result[] = [];
const stream = search.stream(adapter);
stream.on("data", (data: Result) => {
result.push(data);
if (streamFunc !== undefined) streamFunc(data);
});
stream.on("end", () => {
resolve(result);
});
stream.on("error", (e: any) => {
reject(e);
});
});
}
/**
* 更新指定插件
* @param {...string[]} adapters 插件名称