-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.js
33 lines (28 loc) · 1.06 KB
/
install.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require('fs');
const https = require('https');
const destPath = 'dist/vuicc.exe';
function downloadCompiler() {
return new Promise((resolve, reject) => {
const writeStream = fs.createWriteStream('dist/vuicc.exe');
https.get('https://veniceunleashed.net/files/vuicc.exe', (res) => {
if (res.statusCode !== 200) {
writeStream.close();
fs.unlink(destPath, () => {});
reject(new Error(`Server responded with ${res.statusCode}: ${res.statusMessage}`));
return;
}
res.pipe(writeStream)
.on('finish', () => {
resolve();
})
.on('error', (err) => {
writeStream.close();
fs.unlink(destPath, () => {});
reject(err)
});
});
});
}
downloadCompiler()
.then(() => console.log('Successfully downloaded vuicc.exe'))
.catch(err => console.log('An error occured while downloading vuicc.exe:', err));