@@ -53,8 +53,21 @@ export function yamlStringify(value: unknown): string {
5353
5454type CommandOptions = { cwd ?: string ; stdin ?: string | Uint8Array } ;
5555
56+ async function shellCommand ( cmd : string [ ] , options : CommandOptions = { } ) {
57+ const proc = $ `${ cmd } ` . quiet ( ) . nothrow ( ) ;
58+ if ( options . cwd ) {
59+ proc . cwd ( options . cwd ) ;
60+ }
61+ if ( options . stdin !== undefined ) {
62+ const writer = proc . stdin . getWriter ( ) ;
63+ await writer . write ( typeof options . stdin === "string" ? new TextEncoder ( ) . encode ( options . stdin ) : options . stdin ) ;
64+ await writer . close ( ) ;
65+ }
66+ return await proc ;
67+ }
68+
5669export async function runText ( cmd : string [ ] , prefix : string , options : CommandOptions = { } ) : Promise < string > {
57- const proc = await $ ( { cwd : options . cwd , stdin : options . stdin , stdout : "pipe" , stderr : "pipe" } ) ` ${ cmd } ` . nothrow ( ) . quiet ( ) ;
70+ const proc = await shellCommand ( cmd , options ) ;
5871 if ( proc . exitCode !== 0 ) {
5972 const stderr = proc . stderr . toString ( ) . trim ( ) ;
6073 const rendered = stderr || `command failed: ${ cmd . join ( " " ) } ` ;
@@ -72,7 +85,7 @@ export async function runAllowFailure(
7285 cmd : string [ ] ,
7386 options : CommandOptions = { }
7487) : Promise < { exitCode : number ; stdout : string ; stderr : string } > {
75- const proc = await $ ( { cwd : options . cwd , stdin : options . stdin , stdout : "pipe" , stderr : "pipe" } ) ` ${ cmd } ` . nothrow ( ) . quiet ( ) ;
88+ const proc = await shellCommand ( cmd , options ) ;
7689 return {
7790 exitCode : proc . exitCode ,
7891 stdout : proc . stdout . toString ( ) ,
0 commit comments