Simplify conditionals with a switch

This commit is contained in:
Carlos Alcaide Corvo committed 2021-10-15 13:40:14 -07:00
1 parent a07e3f4e41
commit 6bcbf2b2ba
1 file changed
+12 -15
+12 -15
View File
@@ -25,21 +25,18 @@ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => {
*/
exports.returnExecutablePath = (platform, arch) => {
try {
// Just mac
if (platform === 'darwin') {
if (arch === 'x64') {
// Intel chips
return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary';
} else if (arch === 'arm64') {
// M1 chips
return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary';
} else {
throw new Error('The test suite is not compatible with your arch.');
}
} else {
throw new Error(
'The test suite is not compatible with your Platform or Architecture.'
);
switch (platform) {
case 'darwin':
switch (arch) {
case 'x64': // Intel chips
return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary';
case 'arm64': // M1 chips
return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary';
default:
throw new Error('The test suite is not compatible with your arch.');
}
default:
throw new Error('The test suite is not compatible with your platform.');
}
} catch (error) {
console.error(error);