1- import { spawn_out } from '@fuzdev/fuz_util/process.js' ;
1+ import { spawn_out , spawn_result_to_message } from '@fuzdev/fuz_util/process.js' ;
22import type { SpawnOptions } from 'node:child_process' ;
33import {
44 git_check_clean_workspace as gro_git_check_clean_workspace ,
@@ -20,7 +20,9 @@ export const git_add = async (
2020 const file_list = Array . isArray ( files ) ? files : [ files ] ;
2121 const { result, stderr} = await spawn_out ( 'git' , [ 'add' , ...file_list ] , options ) ;
2222 if ( ! result . ok ) {
23- throw Error ( `git_add failed with code ${ result . code } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ) ;
23+ throw Error (
24+ `git_add failed with ${ spawn_result_to_message ( result ) } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
25+ ) ;
2426 }
2527} ;
2628
@@ -30,7 +32,9 @@ export const git_add = async (
3032export const git_commit = async ( message : string , options ?: SpawnOptions ) : Promise < void > => {
3133 const { result, stderr} = await spawn_out ( 'git' , [ 'commit' , '-m' , message ] , options ) ;
3234 if ( ! result . ok ) {
33- throw Error ( `git_commit failed with code ${ result . code } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ) ;
35+ throw Error (
36+ `git_commit failed with ${ spawn_result_to_message ( result ) } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
37+ ) ;
3438 }
3539} ;
3640
@@ -59,7 +63,7 @@ export const git_tag = async (
5963 const { result, stderr} = await spawn_out ( 'git' , args , options ) ;
6064 if ( ! result . ok ) {
6165 throw Error (
62- `git_tag failed for tag '${ tag_name } ' with code ${ result . code } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
66+ `git_tag failed for tag '${ tag_name } ' with ${ spawn_result_to_message ( result ) } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
6367 ) ;
6468 }
6569} ;
@@ -75,7 +79,7 @@ export const git_push_tag = async (
7579 const { result, stderr} = await spawn_out ( 'git' , [ 'push' , origin , tag_name ] , options ) ;
7680 if ( ! result . ok ) {
7781 throw Error (
78- `git_push_tag failed for tag '${ tag_name } ' with code ${ result . code } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
82+ `git_push_tag failed for tag '${ tag_name } ' with ${ spawn_result_to_message ( result ) } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
7983 ) ;
8084 }
8185} ;
@@ -122,7 +126,9 @@ export const git_stash = async (message?: string, options?: SpawnOptions): Promi
122126
123127 const { result, stderr} = await spawn_out ( 'git' , args , options ) ;
124128 if ( ! result . ok ) {
125- throw Error ( `git_stash failed with code ${ result . code } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ) ;
129+ throw Error (
130+ `git_stash failed with ${ spawn_result_to_message ( result ) } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
131+ ) ;
126132 }
127133} ;
128134
@@ -133,7 +139,7 @@ export const git_stash_pop = async (options?: SpawnOptions): Promise<void> => {
133139 const { result, stderr} = await spawn_out ( 'git' , [ 'stash' , 'pop' ] , options ) ;
134140 if ( ! result . ok ) {
135141 throw Error (
136- `git_stash_pop failed with code ${ result . code } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
142+ `git_stash_pop failed with ${ spawn_result_to_message ( result ) } ${ stderr ? ': ' + stderr . trim ( ) : '' } ` ,
137143 ) ;
138144 }
139145} ;
0 commit comments