UNPKG

@keymanapp/kmc

Version:

Keyman Developer compiler command line tools

55 lines (53 loc) 2.31 kB
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9fa49687-35d8-5370-99c7-e55620229c5b")}catch(e){}}(); import { KmnCompiler } from "@keymanapp/kmc-kmn"; import { NodeCompilerCallbacks } from "./NodeCompilerCallbacks.js"; import { KeymanSentry } from '@keymanapp/developer-utils'; const cli = process.argv.join(' '); export class TestKeymanSentry { static isTestCL() { // Note single hyphen match which matches other Developer console app // implementations, but this will also work with // --sentry-client-test-exception, so we get the best of both worlds. // This parameter is undocumented by design return cli.includes('-sentry-client-test-exception'); } static async runTestIfCLRequested(options) { if (TestKeymanSentry.isTestCL()) { await TestKeymanSentry.test(options); console.error('Unexpected return from KeymanSentry.test'); process.exit(1); } } static async test(options) { KeymanSentry.init(options); if (cli.includes('kmcmplib')) { const compiler = new KmnCompiler(); const callbacks = new NodeCompilerCallbacks({}); if (!await compiler.init(callbacks, null)) { throw new Error('Failed to instantiate WASM compiler'); } try { compiler.testSentry(); } catch (e) { await KeymanSentry.captureException(e); } } else if (cli.includes('event')) { const eventId = KeymanSentry.captureMessage('Test message from -sentry-client-test-exception event'); await KeymanSentry.close(); console.log(`Captured test message with id ${eventId}`); process.exit(0); } else { try { throw new Error('Test error from -sentry-client-test-exception event'); } catch (e) { await KeymanSentry.captureException(e, true); } } } } //# sourceMappingURL=TestKeymanSentry.js.map //# debugId=9fa49687-35d8-5370-99c7-e55620229c5b