From d93d011418f65c8dff26bbaabaf28d59cb878648 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 27 Jan 2023 13:21:32 +0100 Subject: [PATCH] New version 05 (#135) * Bumped to version 4.3.0 * Bumped to version 4.3.0 Co-authored-by: fr43nk --- src/clearcase.ts | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/clearcase.ts b/src/clearcase.ts index 2467405..120abb1 100644 --- a/src/clearcase.ts +++ b/src/clearcase.ts @@ -237,10 +237,12 @@ export class ClearCase { new CCArgs(["ls"], [docs[0]?.fsPath]), dirname(docs[0]?.fsPath), null, - () => func(docs), - (error: string) => { - this.outputChannel.appendLine(`clearcase, exec error: ${error}`); - window.showErrorMessage(`${docs[0]?.fsPath} is not a valid ClearCase object.`); + (code: number, _output: string, error: string) => { + if (code !== 0 || error.length > 0) { + window.showErrorMessage(`${docs[0]?.fsPath} is not a valid ClearCase object.`); + } else { + func(docs); + } } ); } @@ -668,8 +670,10 @@ export class ClearCase { new CCArgs(["update"], [updateFsObj]), cwd, () => this.mUpdateEvent.fire([filePath]), - (result: string) => (resultOut = result), - (error: string) => (errorRes = error) + (_code: number, output: string, error: string) => { + errorRes = error; + resultOut = output; + } ); if (errorRes.length > 0) { throw new Error(errorRes); @@ -919,19 +923,16 @@ export class ClearCase { }); command.on("close", (code) => { - if (code !== 0) { - outputChannel.appendLine(cmdErrMsg); - if (isView && cmdErrMsg !== "") { - window.showErrorMessage(`${cmdErrMsg}`, { modal: false }); - reject(cmdErrMsg); - } - if (typeof onFinished === "function") { - onFinished("error"); - } - } else { - if (typeof onFinished === "function") { - onFinished(allData.length > 0 ? allData.toString() : allDataStr); - } + if (cmdErrMsg !== "") { + // If something was printed on stderr, log it, regardless of the exit code + outputChannel.appendLine(`exit code ${code}, stderr: ${cmdErrMsg}`); + } + if (code !== 0 && isView && cmdErrMsg !== "") { + window.showErrorMessage(`${cmdErrMsg}`, { modal: false }); + reject(cmdErrMsg); + } + if (typeof onFinished === "function") { + onFinished(code, allData.length > 0 ? allData.toString() : allDataStr, cmdErrMsg); } resolve(); });