Skip to content

Commit

Permalink
Export download-only function from mod.ts (#7)
Browse files Browse the repository at this point in the history
Export download function
  • Loading branch information
manyuanrong committed Apr 18, 2020
2 parents 9ee8427 + 29049fc commit dc54f90
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ export interface PreprareOptions {
};
}

export async function prepare(options: PreprareOptions) {
const { name, urls, printLog = true, checkCache = true } = options;

if (printLog) {
await log.setup({});
}
export async function download(options: PreprareOptions) {
const { name, urls, checkCache = true } = options;

const remoteUrl = urls[os];
const remoteHash = md5.digest(encode(remoteUrl + pluginSuffix)).hex();
Expand All @@ -53,6 +49,18 @@ export async function prepare(options: PreprareOptions) {
await downloadFromRemote(name, remoteUrl, localPath);
}
}

return localPath;
}

export async function prepare(options: PreprareOptions) {
const { name, printLog = true } = options;

if (printLog) {
await log.setup({});
}

const localPath = await download(options);

log.info(`load deno plugin "${name}" from local "${localPath}"`);
return Deno.openPlugin(localPath);
Expand Down

0 comments on commit dc54f90

Please sign in to comment.