From a33d5882b60886facb4eb133d915143cf3355fec Mon Sep 17 00:00:00 2001 From: almenon Date: Tue, 19 May 2020 07:39:44 -0700 Subject: [PATCH] move output to beginning because it is always arry Also add exitCode and exitSignal --- index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 5a8d1a1..22aaa9b 100644 --- a/index.ts +++ b/index.ts @@ -277,14 +277,14 @@ export class PythonShell extends EventEmitter{ * @param {Function} callback The callback function to invoke with the script results * @return {PythonShell} The PythonShell instance */ - static run(scriptPath:string, options?:Options, callback?:(err?:PythonShellError, output?:any[])=>any) { + static run(scriptPath:string, options?:Options, callback?:(output:ReturnType[], err?:PythonShellError, exitCode?: number, exitSignal?: string)=>any) { let pyshell = new PythonShell(scriptPath, options); let output = []; return pyshell.on('message', function (message) { output.push(message); - }).end(function (err) { - return callback(err? err : null, output.length ? output : null); + }).end(function (err, exitCode, exitSignal) { + return callback(output, err? err : null, exitCode, exitSignal); }); };