|
1 | 1 | const fs = require('fs'); |
2 | | -const request = require('request'); |
| 2 | +const https = require('https'); |
3 | 3 | const tar = require('tar'); |
4 | 4 | const AdmZip = require('adm-zip'); |
5 | 5 | const lzma = require('lzma-native'); |
@@ -48,12 +48,11 @@ async function getPackage(){ |
48 | 48 | if (fs.existsSync(system.typePath)) rimraf(system.typePath); |
49 | 49 | if (!fs.existsSync(`${system.rootDir}/ffmpeg`)) fs.mkdirSync(`${system.rootDir}/ffmpeg`); |
50 | 50 | var downloaded = await new Promise(resolve=>{ |
51 | | - let file = request(system.url); |
52 | | - file.on('error', ()=>resolve(false)); |
53 | | - file.pipe(fs.createWriteStream(system.zipPath)).on('finish', ()=>resolve(true)); |
54 | | - file.on('response', (c)=>{ |
55 | | - let bar = console.bar(parseInt(c.headers['content-length'], 10)); |
56 | | - file.on('data', c=>bar.tick(c.length)); |
| 51 | + https.get(system.url, res => { |
| 52 | + res.on('error', ()=>resolve(false)); |
| 53 | + res.pipe(fs.createWriteStream(system.zipPath)).on('finish', ()=>resolve(true)); |
| 54 | + let bar = console.bar(parseInt(res.headers['content-length'], 10)); |
| 55 | + res.on('data', c=>bar.tick(c.length)); |
57 | 56 | }); |
58 | 57 | }); |
59 | 58 | if (!downloaded) console.error('Unable to download files'); |
|
0 commit comments