Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function downloadInstaller(websitePath) {
const client = followRedirects.https;
const tmpFilePath = makeTmpFileName('october-installer-archive');
var options = config.installerDownloadOptions.wizard;
await new Promise((resolve, reject) => {
const file = fileSystem.createWriteStream(tmpFilePath);
const request = client.get(options);
file.on('error', (err) => {
reject('Unable to save downloaded file');
})
request.on('error', (err) => {
reject('Unable to download the installer: there was a network error. Please check your Internet connection.');
module.exports.download = (uri, dest, progressCallback) => {
progressCallback = progressCallback || function () {};
let parsedUrl = url.parse(uri, false, true);
let makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
let serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
let agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
let file = fs.createWriteStream(dest);
let options = {
host: parsedUrl.host,
path: parsedUrl.path,
agent: agent,
port: serverPort,
method: 'GET',
};
return new Promise((resolve, reject) => {
let req = makeRequest(options, (response) => {
let size = response.headers['content-length'];
let progress = 0;