Skip to content

Commit

Permalink
chore: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Nov 25, 2023
1 parent 075ad8e commit d1120fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
40 changes: 21 additions & 19 deletions packages/commandkit/bin/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,27 @@ export async function bootstrapProductionBuild(config) {
async function injectShims(outDir, main, antiCrash) {
const path = join(process.cwd(), outDir, main);

const antiCrashScript = antiCrash ? [
'\n\n// --- CommandKit Anti-Crash Monitor ---',
';(()=>{',
" 'use strict';",
" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process",
' // instead of using it as a means to resume operation.',
' // But it exists here due to compatibility reasons with discord bot ecosystem.',
" const p = (t) => `\\x1b[33m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';",
' if (!process.eventNames().includes(e1)) // skip if it is already handled',
' process.on(e1, (e) => {',
' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',
' })',
' if (!process.eventNames().includes(e2)) // skip if it is already handled',
' process.on(e2, (r) => {',
' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',
' });',
'})();',
'// --- CommandKit Anti-Crash Monitor ---\n',
].join('\n') : '';
const antiCrashScript = antiCrash
? [
'\n\n// --- CommandKit Anti-Crash Monitor ---',
';(()=>{',
" 'use strict';",
" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process",
' // instead of using it as a means to resume operation.',
' // But it exists here due to compatibility reasons with discord bot ecosystem.',
" const p = (t) => `\\x1b[33m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';",
' if (!process.eventNames().includes(e1)) // skip if it is already handled',
' process.on(e1, (e) => {',
' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',
' })',
' if (!process.eventNames().includes(e2)) // skip if it is already handled',
' process.on(e2, (r) => {',
' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',
' });',
'})();',
'// --- CommandKit Anti-Crash Monitor ---\n',
].join('\n')
: '';

const finalScript = [antiCrashScript].join('\n');

Expand Down
2 changes: 1 addition & 1 deletion packages/commandkit/bin/parse-env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function parseEnv(src) {
if (typeof value !== 'string') continue;

if (value.startsWith(VALUE_PREFIXES.JSON)) {
catcher(() => src[key] = JSON.parse(value.replace(VALUE_PREFIXES.JSON, '')));
catcher(() => (src[key] = JSON.parse(value.replace(VALUE_PREFIXES.JSON, ''))));
continue;
}

Expand Down

0 comments on commit d1120fd

Please sign in to comment.