Prettier support

This commit is contained in:
2021-03-10 21:14:32 -06:00
parent c51b527707
commit 0924490a6f
99 changed files with 5504 additions and 3979 deletions

View File

@@ -3,7 +3,10 @@ const fs = require('fs');
const helpers = require('../../helpers');
const os = require('os');
const addListeners = (ipcMain, {setIsInstalling, unmountAllDrives, standardIPCReply}) => {
const addListeners = (
ipcMain,
{ setIsInstalling, unmountAllDrives, standardIPCReply }
) => {
ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
let allowSkipVerification = true;
@@ -19,25 +22,34 @@ const addListeners = (ipcMain, {setIsInstalling, unmountAllDrives, standardIPCRe
if (tempPub) {
fs.unlinkSync(tempPub);
}
} catch (e) {
}
} catch (e) {}
};
const errorHandler = err => {
const errorHandler = (err) => {
cleanupFiles();
setIsInstalling(false);
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply, {
AllowSkipVerification: allowSkipVerification,
Source: data.Source,
}, err);
standardIPCReply(
event,
Constants.IPC_Install_Upgrade_Reply,
{
AllowSkipVerification: allowSkipVerification,
Source: data.Source,
},
err
);
};
// TODO Enable verification in 1.0.4
const hasSignature = false;//!data.SkipVerification && data.Signature && (data.Signature.length > 0);
const hasHash = false;//!data.SkipVerification && data.Sha256 && (data.Sha256.length > 0);
const hasSignature = false; //! data.SkipVerification && data.Signature
//! && (data.Signature.length > 0);
const hasHash = false; //! data.SkipVerification && data.Sha256 &&
//! (data.Sha256.length > 0);
if (hasSignature) {
try {
const files = helpers.createSignatureFiles(data.Signature, Constants.DEV_PUBLIC_KEY);
const files = helpers.createSignatureFiles(
data.Signature,
Constants.DEV_PUBLIC_KEY
);
tempPub = files.PublicKeyFile;
tempSig = files.SignatureFile;
} catch (e) {
@@ -69,35 +81,37 @@ const addListeners = (ipcMain, {setIsInstalling, unmountAllDrives, standardIPCRe
const executeInstall = () => {
setIsInstalling(true);
helpers
.executeAsync(command, args)
.then(() => {
cleanupFiles();
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply)
})
.catch(error => {
setIsInstalling(false);
errorHandler(error);
});
.executeAsync(command, args)
.then(() => {
cleanupFiles();
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply);
})
.catch((error) => {
setIsInstalling(false);
errorHandler(error);
});
};
if (hasSignature) {
helpers
.verifySignature(data.Source, tempSig, tempPub)
.then(() => {
executeInstall();
})
.catch(() => {
errorHandler(Error('Failed to verify installation package signature'));
});
.verifySignature(data.Source, tempSig, tempPub)
.then(() => {
executeInstall();
})
.catch(() => {
errorHandler(
Error('Failed to verify installation package signature')
);
});
} else if (hasHash) {
helpers
.verifyHash(data.Source, data.Sha256)
.then(()=> {
executeInstall();
})
.catch(() => {
errorHandler(Error('Failed to verify installation package hash'));
});
.verifyHash(data.Source, data.Sha256)
.then(() => {
executeInstall();
})
.catch(() => {
errorHandler(Error('Failed to verify installation package hash'));
});
} else {
if (platform === 'darwin') {
setTimeout(executeInstall, 3000);
@@ -111,6 +125,4 @@ const addListeners = (ipcMain, {setIsInstalling, unmountAllDrives, standardIPCRe
});
};
module.exports = {
addListeners
};
module.exports = { addListeners };