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) => {
const destDir = `${tmpdir()}/chromium-pack`
const extractObj = extract(destDir)
get(url, function (response) {
response.pipe(extractObj);
extractObj.on('finish', () => {
extractObj.end(() => {
resolve(destDir);
export const downloadAndExtract = async (url: string) =>
new Promise<string>((resolve, reject) => {
const destDir = `${tmpdir()}/chromium-pack`
const extractObj = extract(destDir)
get(url, (response) => {
response.pipe(extractObj);
extractObj.on('finish', () => {
extractObj.end(() => {
resolve(destDir);
});
});
}).on('error', (err) => {
unlink(destDir, (_) => {
reject(err)
});
});
}).on('error', (err) => {
unlink(destDir, (_) => {
reject(err)
});
});
})
})