diff options
Diffstat (limited to 'src/commands/dev')
-rw-r--r-- | src/commands/dev/eval.ts | 5 | ||||
-rw-r--r-- | src/commands/dev/javascript.ts | 7 | ||||
-rw-r--r-- | src/commands/dev/sh.ts | 16 |
3 files changed, 15 insertions, 13 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 0f53198..d4c9331 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -263,11 +263,12 @@ export default class EvalCommand extends BushCommand { if (inputTS) embed.addFields([{ name: ':inbox_tray: Input (typescript)', value: inputTS }]); embed.addFields([{ name: `:inbox_tray: Input${inputTS ? ' (transpiled javascript)' : ''}`, value: inputJS }]); - const output = await this.codeblock(rawResult, 'js', { + const output = await this.codeblock(rawResult, 'ansi', { depth: selDepth ?? 0, showHidden: hidden, showProxy: true, - inspectStrings: !noInspectStrings + inspectStrings: !noInspectStrings, + colors: true }); const methods = !err && showMethods ? await this.codeblock(rawResult, 'ts', { methods: true }) : undefined; diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts index d25b790..373f149 100644 --- a/src/commands/dev/javascript.ts +++ b/src/commands/dev/javascript.ts @@ -60,10 +60,11 @@ export default class JavascriptCommand extends BushCommand { const rawOutput = /^(9\s*?\+\s*?10)|(10\s*?\+\s*?9)$/.test(code) ? '21' : new VM({ eval: true, wasm: true, timeout: 1_000, fixAsync: true }).run(`${code}`); - const output = await util.inspectCleanRedactCodeblock(rawOutput, 'js', { + const output = await util.inspectCleanRedactCodeblock(rawOutput, 'ansi', { depth: args.sel_depth ?? 0, getters: true, - inspectStrings: true + inspectStrings: true, + colors: true }); embed.setTitle(`${util.emojis.successFull} Successfully Evaluated Expression`).setColor(util.colors.success); @@ -75,7 +76,7 @@ export default class JavascriptCommand extends BushCommand { embed.setTitle(`${util.emojis.errorFull} Unable to Evaluate Expression`).setColor(util.colors.error); embed.addFields([ { name: '📥 Input', value: input }, - { name: '📤 Error', value: await util.inspectCleanRedactCodeblock(e, 'js') } + { name: '📤 Error', value: await util.inspectCleanRedactCodeblock(e, 'ansi', { colors: true }) } ]); } diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index e071e73..d47ecd2 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -57,32 +57,32 @@ export default class ShCommand extends BushCommand { await message.util.reply({ embeds: [embed] }); - const pattern = [ + /* const pattern = [ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' ].join('|'); function strip(abc: string): string { return abc.replace(new RegExp(pattern, 'g'), ''); - } + } */ try { - const output = await sh(command); - const stdout = strip(clean(output.stdout)); - const stderr = strip(clean(output.stderr)); + const output = await sh(command, { env: { ...process.env, FORCE_COLOR: 'true' } }); + const stdout = /* strip( */ clean(output.stdout); /* ) */ + const stderr = /* strip( */ clean(output.stderr); /* ) */ embed .setTitle(`${util.emojis.successFull} Executed command successfully.`) .setColor(util.colors.success) .spliceFields(1, 1); - if (stdout) embed.addFields([{ name: '📤 stdout', value: await util.codeblock(stdout, 1024, 'json', true) }]); - if (stderr) embed.addFields([{ name: '📤 stderr', value: await util.codeblock(stderr, 1024, 'json', true) }]); + if (stdout) embed.addFields([{ name: '📤 stdout', value: await util.codeblock(stdout, 1024, 'ansi', true) }]); + if (stderr) embed.addFields([{ name: '📤 stderr', value: await util.codeblock(stderr, 1024, 'ansi', true) }]); } catch (e) { embed .setTitle(`${util.emojis.errorFull} An error occurred while executing.`) .setColor(util.colors.error) .spliceFields(1, 1); - embed.addFields([{ name: '📤 Output', value: await util.codeblock(util.formatError(e), 1024, 'js', true) }]); + embed.addFields([{ name: '📤 Output', value: await util.codeblock(util.formatError(e, true), 1024, 'ansi', true) }]); } await message.util.edit({ embeds: [embed] }); } |