@@ -10,7 +10,9 @@ import path from 'node:path'
1010
1111import { whichBinSync } from '@socketsecurity/lib/bin'
1212
13- import { exec , execCapture } from './build-exec.mjs'
13+ import { WIN32 } from '@socketsecurity/lib/constants/platform'
14+ import { spawn } from '@socketsecurity/lib/spawn'
15+
1416import { printError , printStep , printWarning } from './build-output.mjs'
1517
1618/**
@@ -24,8 +26,12 @@ export async function checkDiskSpace(dir, requiredGB = 5) {
2426 printStep ( 'Checking disk space' )
2527
2628 try {
27- const { stdout } = await execCapture ( `df -k "${ dir } "` )
28- const lines = stdout . trim ( ) . split ( '\n' )
29+ const result = await spawn ( `df -k "${ dir } "` , [ ] , {
30+ shell : WIN32 ,
31+ stdio : 'pipe' ,
32+ stdioString : true ,
33+ } )
34+ const lines = ( result . stdout ?? '' ) . trim ( ) . split ( '\n' )
2935 if ( lines . length < 2 ) {
3036 printWarning ( 'Could not determine disk space' )
3137 return { availableGB : null , sufficient : true }
@@ -83,10 +89,12 @@ export async function checkPythonVersion(minVersion = '3.6') {
8389 printStep ( 'Checking Python version' )
8490
8591 try {
86- const { stdout } = await execCapture (
87- 'python3 -c "import sys; print(f\'{sys.version_info.major}.{sys.version_info.minor}\')"'
92+ const result = await spawn (
93+ 'python3 -c "import sys; print(f\'{sys.version_info.major}.{sys.version_info.minor}\')"' ,
94+ [ ] ,
95+ { shell : WIN32 , stdio : 'pipe' , stdioString : true }
8896 )
89- const version = stdout . trim ( )
97+ const version = ( result . stdout ?? '' ) . trim ( )
9098 const [ major , minor ] = version . split ( '.' ) . map ( Number )
9199 const [ minMajor , minMinor ] = minVersion . split ( '.' ) . map ( Number )
92100
@@ -159,9 +167,13 @@ export async function smokeTestBinary(binaryPath, args = ['--version']) {
159167
160168 try {
161169 await fs . access ( binaryPath )
162- const { code } = await execCapture ( `${ binaryPath } ${ args . join ( ' ' ) } ` )
170+ const result = await spawn ( `${ binaryPath } ${ args . join ( ' ' ) } ` , [ ] , {
171+ shell : WIN32 ,
172+ stdio : 'pipe' ,
173+ stdioString : true ,
174+ } )
163175
164- if ( code !== 0 ) {
176+ if ( ( result . status ?? 0 ) !== 0 ) {
165177 printError ( `Binary failed smoke test: ${ binaryPath } ` )
166178 return false
167179 }
@@ -303,11 +315,13 @@ export async function cleanCheckpoint(buildDir) {
303315export async function checkNetworkConnectivity ( ) {
304316 try {
305317 // Try to reach GitHub (where we clone from).
306- const result = await execCapture (
307- 'curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 https://github.com'
318+ const result = await spawn (
319+ 'curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 https://github.com' ,
320+ [ ] ,
321+ { shell : WIN32 , stdio : 'pipe' , stdioString : true }
308322 )
309323
310- const statusCode = result . stdout . trim ( )
324+ const statusCode = ( result . stdout ?? '' ) . trim ( )
311325 return {
312326 connected :
313327 statusCode === '200' || statusCode === '301' || statusCode === '302' ,
@@ -326,12 +340,14 @@ export async function checkNetworkConnectivity() {
326340 */
327341export async function verifyGitTag ( version ) {
328342 try {
329- const result = await execCapture (
330- `git ls-remote --tags https://github.com/nodejs/node.git ${ version } `
343+ const result = await spawn (
344+ `git ls-remote --tags https://github.com/nodejs/node.git ${ version } ` ,
345+ [ ] ,
346+ { shell : WIN32 , stdio : 'pipe' , stdioString : true }
331347 )
332348
333349 return {
334- exists : result . stdout . includes ( version ) ,
350+ exists : ( result . stdout ?? '' ) . includes ( version ) ,
335351 output : result . stdout ,
336352 }
337353 } catch {
0 commit comments