PoC Electron app (#264)
Initial version of Electron wrapper + build pipeline
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import axios from "axios";
|
||||
import fs from "node:fs";
|
||||
|
||||
export async function downloadFile(
|
||||
url: string,
|
||||
destFile: string,
|
||||
): Promise<void> {
|
||||
const file = fs.createWriteStream(destFile);
|
||||
let response = await axios.request({
|
||||
url: url,
|
||||
method: "GET",
|
||||
responseType: "stream",
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
response.data.pipe(file);
|
||||
let error: Error | null = null;
|
||||
file.on("error", (e) => {
|
||||
error = e;
|
||||
reject(e);
|
||||
});
|
||||
file.on("close", () => {
|
||||
if (error) {
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user