insomnia/packages/insomnia-app/app/common/validate-insomnia-config.ts
Dimitri Mitropoulos dddacb9eaa
block starting the app if there's an invalid config (#4132)
Co-authored-by: Opender Singh <opender.singh@konghq.com>
2021-10-19 22:10:48 -04:00

24 lines
664 B
TypeScript

import electron from 'electron';
import { omit } from 'ramda';
import { getConfigSettings } from '../models/helpers/settings';
import { exitApp } from './electron-helpers';
export const validateInsomniaConfig = () => {
const configSettings = getConfigSettings();
if ('error' in configSettings) {
const errors = configSettings.error.errors?.map(omit(['parentSchema', 'data']));
electron.dialog.showErrorBox('Invalid Insomnia Config',
[
`Invalid Insomnia Config found at "${configSettings.error.configPath}"`,
'',
'errors:',
`${JSON.stringify(errors, null, 2)}`,
].join('\n'),
);
exitApp();
}
};