fix: Fix console log handling in JS task runner (no-changelog) (#11147)

This commit is contained in:
Tomi Turtiainen
2024-10-08 16:32:50 +03:00
committed by GitHub
parent 606eedbf1b
commit 18c0c8612c
2 changed files with 12 additions and 56 deletions

View File

@@ -74,8 +74,6 @@ type CustomConsole = {
log: (...args: unknown[]) => void;
};
const noop = () => {};
export class JsTaskRunner extends TaskRunner {
constructor(
taskType: string,
@@ -110,16 +108,14 @@ export class JsTaskRunner extends TaskRunner {
});
const customConsole = {
log:
settings.workflowMode === 'manual'
? noop
: (...args: unknown[]) => {
const logOutput = args
.map((arg) => (typeof arg === 'object' && arg !== null ? JSON.stringify(arg) : arg))
.join(' ');
console.log('[JS Code]', logOutput);
void this.makeRpcCall(task.taskId, 'logNodeOutput', [logOutput]);
},
// Send log output back to the main process. It will take care of forwarding
// it to the UI or printing to console.
log: (...args: unknown[]) => {
const logOutput = args
.map((arg) => (typeof arg === 'object' && arg !== null ? JSON.stringify(arg) : arg))
.join(' ');
void this.makeRpcCall(task.taskId, 'logNodeOutput', [logOutput]);
},
};
const result =