chore: resolve comment

This commit is contained in:
Vu Nguyen 2023-01-11 09:35:18 +07:00
parent 3deea91193
commit 9e34256b2f
1 changed files with 15 additions and 14 deletions

View File

@ -11,19 +11,20 @@ export const isValidUrl = (input: string) => {
} }
} }
export const downloadAndExtract = async (url: string): Promise<string> => new Promise((resolve, reject) => { export const downloadAndExtract = async (url: string) =>
const destDir = `${tmpdir()}/chromium-pack` new Promise<string>((resolve, reject) => {
const extractObj = extract(destDir) const destDir = `${tmpdir()}/chromium-pack`
get(url, function (response) { const extractObj = extract(destDir)
response.pipe(extractObj); get(url, (response) => {
extractObj.on('finish', () => { response.pipe(extractObj);
extractObj.end(() => { extractObj.on('finish', () => {
resolve(destDir); extractObj.end(() => {
resolve(destDir);
});
});
}).on('error', (err) => {
unlink(destDir, (_) => {
reject(err)
}); });
}); });
}).on('error', (err) => { })
unlink(destDir, (_) => {
reject(err)
});
});
})