21 lines
701 B
JavaScript
21 lines
701 B
JavaScript
const fs = require('fs');
|
|
const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
const AdmZip = require('adm-zip');
|
|
const { logger, ErrorLogger, logRequestInfo } = require('../config/logs');
|
|
|
|
function compareAndUpdate(currentPath, updatedPath) {
|
|
}
|
|
|
|
async function downloadUpdate(updateUrl, destinationPath) {
|
|
const response = await fetch(updateUrl);
|
|
const buffer = await response.buffer();
|
|
fs.writeFileSync(destinationPath, buffer);
|
|
}
|
|
|
|
function unzipUpdate(zipPath, extractionPath) {
|
|
const zip = new AdmZip(zipPath);
|
|
zip.extractAllTo(extractionPath, /*overwrite*/ true);
|
|
}
|
|
|
|
module.exports = { compareAndUpdate, downloadUpdate, unzipUpdate };
|