@@ -14,6 +14,10 @@ class CommandFailedError extends Error {
1414 }
1515}
1616
17+ const pnpmExecPath = process . env . npm_execpath
18+ const runPnpmWithNode =
19+ typeof pnpmExecPath === 'string' && pnpmExecPath . toLowerCase ( ) . includes ( 'pnpm' )
20+
1721const args = process . argv . slice ( 2 )
1822let mode = 'changed'
1923let verbose = false
@@ -68,6 +72,16 @@ function runCommand(step, command, args, options = {}) {
6872 }
6973}
7074
75+ function runPnpm ( step , pnpmArgs ) {
76+ if ( runPnpmWithNode ) {
77+ runCommand ( step , process . execPath , [ pnpmExecPath , ...pnpmArgs ] )
78+ return
79+ }
80+
81+ const command = process . platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
82+ runCommand ( step , command , pnpmArgs )
83+ }
84+
7185function runCapture ( command , args ) {
7286 if ( verbose ) {
7387 console . log ( `[qa:verbose] inspect: ${ command } ${ args . join ( ' ' ) } ` )
@@ -164,18 +178,18 @@ function runWorkspaceQa(modeValue, sinceRef) {
164178
165179 if ( modeValue === 'all' ) {
166180 console . log ( '[qa] run workspace qa (all)' )
167- runCommand ( 'workspace-qa-all' , 'pnpm ', recursiveArgs )
181+ runPnpm ( 'workspace-qa-all' , recursiveArgs )
168182 return
169183 }
170184
171185 if ( ! sinceRef ) {
172186 console . log ( '[qa] no base ref found, fallback to workspace qa (all)' )
173- runCommand ( 'workspace-qa-fallback-all' , 'pnpm ', recursiveArgs )
187+ runPnpm ( 'workspace-qa-fallback-all' , recursiveArgs )
174188 return
175189 }
176190
177191 console . log ( `[qa] run workspace qa (changed since ${ sinceRef } )` )
178- runCommand ( 'workspace-qa-changed' , 'pnpm ', [
192+ runPnpm ( 'workspace-qa-changed' , [
179193 '--filter' ,
180194 `[${ sinceRef } ]` ,
181195 ...recursiveArgs ,
@@ -185,7 +199,7 @@ function runWorkspaceQa(modeValue, sinceRef) {
185199function runRootPwshQa ( modeValue , sinceRef ) {
186200 if ( modeValue === 'all' ) {
187201 console . log ( '[qa] run root qa:pwsh (all)' )
188- runCommand ( 'root-qa-pwsh-all' , 'pnpm ', [ 'run' , 'qa:pwsh' ] )
202+ runPnpm ( 'root-qa-pwsh-all' , [ 'run' , 'qa:pwsh' ] )
189203 return
190204 }
191205
@@ -204,7 +218,7 @@ function runRootPwshQa(modeValue, sinceRef) {
204218 }
205219
206220 console . log ( '[qa] run root qa:pwsh (changed)' )
207- runCommand ( 'root-qa-pwsh-changed' , 'pnpm ', [ 'run' , 'qa:pwsh' ] )
221+ runPnpm ( 'root-qa-pwsh-changed' , [ 'run' , 'qa:pwsh' ] )
208222}
209223
210224const sinceRef = mode === 'changed' ? resolveSinceRef ( ) : null
@@ -238,4 +252,4 @@ try {
238252 }
239253
240254 throw error
241- }
255+ }
0 commit comments