File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { execFile } from "node:child_process" ;
22import type * as VSCode from "vscode" ;
33import { patchloomNeedsUpgrade , resolvePatchloomStatus } from "../binary/patchloom.js" ;
4+ import { formatCliOutput } from "../util.js" ;
45import { getPatchloomLog } from "../logging/outputChannel.js" ;
56import { activeWorkspaceFolder } from "../workspace/readiness.js" ;
67
@@ -135,10 +136,5 @@ function executePatchloomWithStdin(
135136}
136137
137138function formatBatchOutput ( result : BatchCommandResult ) : string {
138- const output = `${ result . stderr } \n${ result . stdout } `
139- . split ( / \r ? \n / )
140- . map ( ( line ) => line . trim ( ) )
141- . filter ( ( line ) => line . length > 0 )
142- . join ( " " ) ;
143- return output || `exit code ${ result . exitCode } ` ;
139+ return formatCliOutput ( result ) ;
144140}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { promisify } from "node:util";
66import type * as VSCode from "vscode" ;
77import { patchloomNeedsUpgrade , resolvePatchloomStatus } from "../binary/patchloom.js" ;
88import { getPatchloomLog } from "../logging/outputChannel.js" ;
9- import { formatError } from "../util.js" ;
9+ import { formatCliOutput , formatError } from "../util.js" ;
1010import { activeWorkspaceFolder , describeWorkspaceEnvironment } from "../workspace/readiness.js" ;
1111
1212const execFileAsync = promisify ( execFile ) ;
@@ -641,12 +641,7 @@ async function executePatchloom(
641641}
642642
643643function formatPatchloomOutput ( result : PatchloomCommandResult ) : string {
644- const output = `${ result . stderr } \n${ result . stdout } `
645- . split ( / \r ? \n / )
646- . map ( ( line ) => line . trim ( ) )
647- . filter ( ( line ) => line . length > 0 )
648- . join ( " " ) ;
649- return output || `exit code ${ result . exitCode } ` ;
644+ return formatCliOutput ( result ) ;
650645}
651646
652647function sameFilePath ( left : string , right : string ) : boolean {
Original file line number Diff line number Diff line change @@ -3,4 +3,13 @@ export function formatError(error: unknown): string {
33 return error . message ;
44 }
55 return String ( error ) ;
6+ }
7+
8+ export function formatCliOutput ( result : { exitCode : number ; stdout : string ; stderr : string } ) : string {
9+ const output = `${ result . stderr } \n${ result . stdout } `
10+ . split ( / \r ? \n / )
11+ . map ( ( line ) => line . trim ( ) )
12+ . filter ( ( line ) => line . length > 0 )
13+ . join ( " " ) ;
14+ return output || `exit code ${ result . exitCode } ` ;
615}
You can’t perform that action at this time.
0 commit comments