@@ -2,6 +2,7 @@ import { spawnSync } from 'node:child_process'
22import { resolve } from 'node:path'
33
44const repositoryRoot = resolve ( __dirname , '../../../..' )
5+ const salesforceCliPackage = '@salesforce/cli@2.139.6'
56
67export const salesforceLwcBundlePath = resolve (
78 repositoryRoot ,
@@ -11,12 +12,15 @@ export const salesforceLwcBundlePath = resolve(
1112// Check if the Salesforce org is configured
1213export function getSalesforceConfig ( ) : { targetOrg : string ; isConfigured : boolean } {
1314 const targetOrg = process . env . SF_TARGET_ORG ?? 'sf-lwc-ci'
14- const isConfigured =
15- spawnSync ( 'sf' , [ 'org' , 'display' , '--target-org' , targetOrg ] , {
16- encoding : 'utf8' ,
17- cwd : repositoryRoot ,
18- } ) . status === 0
19- return { targetOrg, isConfigured }
15+ const args = [ 'org' , 'display' , '--target-org' , targetOrg ]
16+ const options = { encoding : 'utf8' as const , cwd : repositoryRoot }
17+
18+ let result = spawnSync ( 'sf' , args , options )
19+ if ( result . error && ( result . error as NodeJS . ErrnoException ) . code === 'ENOENT' ) {
20+ result = spawnSync ( 'yarn' , [ 'dlx' , '-p' , salesforceCliPackage , 'sf' , ...args ] , options )
21+ }
22+
23+ return { targetOrg, isConfigured : result . status === 0 }
2024}
2125
2226// Build the URL to open in the test browser
0 commit comments