Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rawgithub(url, function(err, data){
// => returns the file contents as a string
if(err){console.log(err);console.log(url);process.exit(0);}
console.log("Github ver:"+JSON.parse(data).app);
console.log("Local ver:"+currentver.app);
rimraf.sync(path.resolve(tmp_path,"./"+reponame));
if(fs.existsSync(path.resolve(__dirname,"./update.zip"))) fs.unlinkSync(path.resolve(__dirname, "./update.zip"));
if(parseFloat(JSON.parse(data).app)==parseFloat(currentver.app)) {
fs.writeFileSync(path.resolve(__dirname,"./update.track"),"updated");
process.exit(0);
}
else
{
fs.writeFileSync(path.resolve(__dirname,"./update.track"),"downloading");
httpreq.download(
urlzip,
path.resolve(__dirname,"./update.zip")
, function (err, progress){
if (err) return console.log(err);
console.log(progress);
}, function (err, res){
if (err) return console.log(err);
console.log(res);
fs.createReadStream(path.resolve(__dirname + "/update.zip")).pipe(unzip.Extract({ path:tmp_path }))
.on('finish', function () {
console.log('chmoding...');
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_macx32'));}catch(err){;};
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x32'));}catch(err){;};
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x32.exe'));}catch(err){;};
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x64'));}catch(err){;};
return new Promise((resolve, reject) => {
request.download(url, tempPath, (err, progress) => {
if (err) {
return reject(err);
}
if (progress.statusCode !== 200) {
return reject(progress.statusCode);
}
resolve(tempPath);
});
});
}