@@ -2,7 +2,7 @@ import { execFileSync, spawnSync } from "node:child_process"
22import { cpSync , existsSync , mkdtempSync , readdirSync , rmSync , writeFileSync } from "node:fs"
33import { tmpdir } from "node:os"
44import { dirname , join , resolve } from "node:path"
5- import { resolveCommand , trimOutput } from "./command.mjs"
5+ import { resolveCommand , resolveSpawnOptions , trimOutput } from "./command.mjs"
66import { readSpawndockConfig } from "./config.mjs"
77
88const cwd = process . cwd ( )
@@ -65,7 +65,12 @@ function deployToGhPagesBranch(remoteUrl) {
6565 run ( "git" , [ "-C" , tempDir , "commit" , "-m" , "Deploy SpawnDock app to GitHub Pages" ] , undefined , true )
6666 run ( "git" , [ "-C" , tempDir , "push" , remoteUrl , "gh-pages" , "--force" ] )
6767 } finally {
68- spawnSync ( resolveCommand ( "git" ) , [ "worktree" , "remove" , tempDir , "--force" ] , { cwd, stdio : "ignore" } )
68+ const gitCommand = resolveCommand ( "git" )
69+ spawnSync ( gitCommand , [ "worktree" , "remove" , tempDir , "--force" ] , {
70+ cwd,
71+ stdio : "ignore" ,
72+ ...resolveSpawnOptions ( gitCommand ) ,
73+ } )
6974 rmSync ( tempDir , { recursive : true , force : true } )
7075 }
7176}
@@ -99,20 +104,24 @@ function enablePages(repoFullName) {
99104}
100105
101106function remoteBranchExists ( branch ) {
102- const result = spawnSync ( resolveCommand ( "git" ) , [ "ls-remote" , "--heads" , "origin" , branch ] , {
107+ const gitCommand = resolveCommand ( "git" )
108+ const result = spawnSync ( gitCommand , [ "ls-remote" , "--heads" , "origin" , branch ] , {
103109 cwd,
104110 encoding : "utf8" ,
105111 stdio : "pipe" ,
112+ ...resolveSpawnOptions ( gitCommand ) ,
106113 } )
107114
108115 return result . status === 0 && trimOutput ( result . stdout ) . length > 0
109116}
110117
111118function getOriginUrl ( ) {
112- const result = spawnSync ( resolveCommand ( "git" ) , [ "remote" , "get-url" , "origin" ] , {
119+ const gitCommand = resolveCommand ( "git" )
120+ const result = spawnSync ( gitCommand , [ "remote" , "get-url" , "origin" ] , {
113121 cwd,
114122 encoding : "utf8" ,
115123 stdio : "pipe" ,
124+ ...resolveSpawnOptions ( gitCommand ) ,
116125 } )
117126
118127 return result . status === 0 ? trimOutput ( result . stdout ) : null
@@ -126,10 +135,12 @@ function clearDirectory(dir) {
126135}
127136
128137function readGh ( ...args ) {
129- const result = spawnSync ( resolveCommand ( "gh" ) , args , {
138+ const ghCommand = resolveCommand ( "gh" )
139+ const result = spawnSync ( ghCommand , args , {
130140 cwd,
131141 encoding : "utf8" ,
132142 stdio : "pipe" ,
143+ ...resolveSpawnOptions ( ghCommand ) ,
133144 } )
134145
135146 if ( result . status !== 0 ) {
@@ -146,11 +157,13 @@ function run(command, args, env = process.env, allowEmptyCommit = false) {
146157 ? [ ...args , "--allow-empty" ]
147158 : args
148159
149- const result = spawnSync ( resolveCommand ( command ) , finalArgs , {
160+ const resolvedCommand = resolveCommand ( command )
161+ const result = spawnSync ( resolvedCommand , finalArgs , {
150162 cwd,
151163 env,
152164 encoding : "utf8" ,
153165 stdio : "inherit" ,
166+ ...resolveSpawnOptions ( resolvedCommand ) ,
154167 } )
155168
156169 if ( result . status !== 0 ) {
0 commit comments