11import { Buffer } from "node:buffer" ;
2- import { spawnSync } from "node:child_process" ;
32import {
43 constants ,
54 accessSync ,
@@ -163,6 +162,7 @@ import {
163162 recomputeScope ,
164163 safeExistsSync ,
165164 safeMkdirSync ,
165+ safeSpawnSync ,
166166 shouldFetchLicense ,
167167 splitOutputByGradleProjects ,
168168} from "../helpers/utils.js" ;
@@ -1660,7 +1660,7 @@ export async function createJavaBom(path, options) {
16601660 `Executing '${ mavenCmd } ${ mvnArgs . join ( " " ) } ' in` ,
16611661 basePath ,
16621662 ) ;
1663- result = spawnSync ( mavenCmd , mvnArgs , {
1663+ result = safeSpawnSync ( mavenCmd , mvnArgs , {
16641664 cwd : basePath ,
16651665 shell : true ,
16661666 encoding : "utf-8" ,
@@ -1709,7 +1709,7 @@ export async function createJavaBom(path, options) {
17091709 thoughtLog (
17101710 "What is the parent component here? Let's use maven command to find out." ,
17111711 ) ;
1712- result = spawnSync (
1712+ result = safeSpawnSync (
17131713 "mvn" ,
17141714 [ "dependency:tree" , "-N" , `-DoutputFile=${ tempMvnParentTree } ` ] ,
17151715 {
@@ -1748,7 +1748,7 @@ export async function createJavaBom(path, options) {
17481748 ) ;
17491749 }
17501750 // Prefer the built-in maven
1751- result = spawnSync (
1751+ result = safeSpawnSync (
17521752 PREFER_MAVEN_DEPS_TREE ? "mvn" : mavenCmd ,
17531753 mvnTreeArgs ,
17541754 {
@@ -2147,7 +2147,7 @@ export async function createJavaBom(path, options) {
21472147 thoughtLog (
21482148 `Let's invoke '${ basename ( gradleCmd ) } ' with the arguments '${ gradleArg . join ( " " ) . substring ( 0 , 100 ) } ...'.` ,
21492149 ) ;
2150- const sresult = spawnSync ( gradleCmd , gradleArg , {
2150+ const sresult = safeSpawnSync ( gradleCmd , gradleArg , {
21512151 cwd : gradleRootPath ,
21522152 encoding : "utf-8" ,
21532153 shell : isWin ,
@@ -2232,7 +2232,7 @@ export async function createJavaBom(path, options) {
22322232 if ( DEBUG_MODE ) {
22332233 console . log ( "Stopping gradle daemon..." ) ;
22342234 }
2235- const sresult = spawnSync ( gradleCmd , [ "--stop" ] , {
2235+ const sresult = safeSpawnSync ( gradleCmd , [ "--stop" ] , {
22362236 cwd : gradleRootPath ,
22372237 encoding : "utf-8" ,
22382238 shell : isWin ,
@@ -2293,7 +2293,7 @@ export async function createJavaBom(path, options) {
22932293 bArgs = [ "--bazelrc=.bazelrc" , "build" , bazelTarget ] ;
22942294 }
22952295 console . log ( "Executing" , BAZEL_CMD , bArgs . join ( " " ) , "in" , basePath ) ;
2296- let result = spawnSync ( BAZEL_CMD , bArgs , {
2296+ let result = safeSpawnSync ( BAZEL_CMD , bArgs , {
22972297 cwd : basePath ,
22982298 shell : true ,
22992299 encoding : "utf-8" ,
@@ -2331,7 +2331,7 @@ export async function createJavaBom(path, options) {
23312331 bazelParser = parseBazelSkyframe ;
23322332 }
23332333 console . log ( "Executing" , BAZEL_CMD , `${ query . join ( " " ) } in` , basePath ) ;
2334- result = spawnSync ( BAZEL_CMD , query , {
2334+ result = safeSpawnSync ( BAZEL_CMD , query , {
23352335 cwd : basePath ,
23362336 encoding : "utf-8" ,
23372337 timeout : TIMEOUT_MS ,
@@ -2509,7 +2509,7 @@ export async function createJavaBom(path, options) {
25092509 tempSbtgDir ,
25102510 ) ;
25112511 // Note that the command has to be invoked with `shell: true` to properly execut sbt
2512- const result = spawnSync ( SBT_CMD , sbtArgs , {
2512+ const result = safeSpawnSync ( SBT_CMD , sbtArgs , {
25132513 cwd : basePath ,
25142514 shell : true ,
25152515 encoding : "utf-8" ,
@@ -2628,7 +2628,7 @@ export async function createJavaBom(path, options) {
26282628 if ( DEBUG_MODE ) {
26292629 console . log ( "Executing" , millCmd , millArgs . join ( " " ) , "in" , millRootPath ) ;
26302630 }
2631- let sresult = spawnSync ( millCmd , millArgs , {
2631+ let sresult = safeSpawnSync ( millCmd , millArgs , {
26322632 cwd : millRootPath ,
26332633 encoding : "utf-8" ,
26342634 shell : isWin ,
@@ -2651,7 +2651,7 @@ export async function createJavaBom(path, options) {
26512651 millRootPath ,
26522652 ) ;
26532653 }
2654- sresult = spawnSync ( millCmd , millResolveArgs , {
2654+ sresult = safeSpawnSync ( millCmd , millResolveArgs , {
26552655 cwd : millRootPath ,
26562656 encoding : "utf-8" ,
26572657 shell : isWin ,
@@ -2717,7 +2717,7 @@ export async function createJavaBom(path, options) {
27172717 if ( DEBUG_MODE ) {
27182718 console . log ( "Shutting down mill server..." ) ;
27192719 }
2720- const sresult = spawnSync ( millCmd , [ "shutdown" ] , {
2720+ const sresult = safeSpawnSync ( millCmd , [ "shutdown" ] , {
27212721 cwd : millRootPath ,
27222722 encoding : "utf-8" ,
27232723 shell : isWin ,
@@ -2943,7 +2943,7 @@ export async function createNodejsBom(path, options) {
29432943 `Executing '${ pkgMgr } ${ installArgs . join ( " " ) } ' in` ,
29442944 basePath ,
29452945 ) ;
2946- const result = spawnSync ( pkgMgr , installArgs , {
2946+ const result = safeSpawnSync ( pkgMgr , installArgs , {
29472947 cwd : basePath ,
29482948 encoding : "utf-8" ,
29492949 timeout : TIMEOUT_MS ,
@@ -3270,7 +3270,7 @@ export async function createNodejsBom(path, options) {
32703270 // Do rush install if we don't have node_modules directory
32713271 if ( ! safeExistsSync ( nmDir ) ) {
32723272 console . log ( "Executing 'rush install --no-link'" , path ) ;
3273- const result = spawnSync (
3273+ const result = safeSpawnSync (
32743274 "rush" ,
32753275 [ "install" , "--no-link" , "--bypass-policy" ] ,
32763276 {
@@ -3806,7 +3806,7 @@ export async function createPythonBom(path, options) {
38063806 if ( requirementsMode || pipenvMode ) {
38073807 if ( pipenvMode ) {
38083808 // TODO: Support for nested directories
3809- spawnSync ( "pipenv" , [ "install" ] , { cwd : path , encoding : "utf-8" } ) ;
3809+ safeSpawnSync ( "pipenv" , [ "install" ] , { cwd : path , encoding : "utf-8" } ) ;
38103810 const piplockFile = join ( path , "Pipfile.lock" ) ;
38113811 if ( safeExistsSync ( piplockFile ) ) {
38123812 const lockData = JSON . parse ( readFileSync ( piplockFile ) ) ;
@@ -4148,7 +4148,7 @@ export async function createGoBom(path, options) {
41484148 if ( DEBUG_MODE ) {
41494149 console . log ( `go mod why -m -vendor ${ pkgFullName } ` ) ;
41504150 }
4151- const mresult = spawnSync (
4151+ const mresult = safeSpawnSync (
41524152 "go" ,
41534153 [ "mod" , "why" , "-m" , "-vendor" , pkgFullName ] ,
41544154 {
@@ -4250,7 +4250,7 @@ export async function createGoBom(path, options) {
42504250 if ( DEBUG_MODE ) {
42514251 console . log ( "Executing go list -deps in" , basePath ) ;
42524252 }
4253- let result = spawnSync (
4253+ let result = safeSpawnSync (
42544254 "go" ,
42554255 [
42564256 "list" ,
@@ -4298,7 +4298,7 @@ export async function createGoBom(path, options) {
42984298 console . log ( "Executing go mod graph in" , basePath ) ;
42994299 }
43004300 // Next we use the go mod graph command to construct the dependency tree
4301- result = spawnSync ( "go" , [ "mod" , "graph" ] , {
4301+ result = safeSpawnSync ( "go" , [ "mod" , "graph" ] , {
43024302 cwd : basePath ,
43034303 encoding : "utf-8" ,
43044304 timeout : TIMEOUT_MS ,
@@ -4351,7 +4351,7 @@ export async function createGoBom(path, options) {
43514351 console . log ( "Executing go mod graph in" , basePath ) ;
43524352 }
43534353 // Next we use the go mod graph command to construct the dependency tree
4354- result = spawnSync ( "go" , [ "mod" , "graph" ] , {
4354+ result = safeSpawnSync ( "go" , [ "mod" , "graph" ] , {
43554355 cwd : basePath ,
43564356 encoding : "utf-8" ,
43574357 timeout : TIMEOUT_MS ,
@@ -4541,7 +4541,7 @@ export async function createRustBom(path, options) {
45414541 basePath ,
45424542 ) ;
45434543 }
4544- const cargoInstallResult = spawnSync ( CARGO_CMD , cargoArgs , {
4544+ const cargoInstallResult = safeSpawnSync ( CARGO_CMD , cargoArgs , {
45454545 cwd : basePath ,
45464546 encoding : "utf-8" ,
45474547 shell : isWin ,
@@ -4907,7 +4907,7 @@ export function createClojureBom(path, options) {
49074907 }
49084908 const basePath = dirname ( f ) ;
49094909 console . log ( "Executing" , LEIN_CMD , LEIN_ARGS . join ( " " ) , "in" , basePath ) ;
4910- const result = spawnSync ( LEIN_CMD , LEIN_ARGS , {
4910+ const result = safeSpawnSync ( LEIN_CMD , LEIN_ARGS , {
49114911 cwd : basePath ,
49124912 encoding : "utf-8" ,
49134913 timeout : TIMEOUT_MS ,
@@ -4956,7 +4956,7 @@ export function createClojureBom(path, options) {
49564956 for ( const f of ednFiles ) {
49574957 const basePath = dirname ( f ) ;
49584958 console . log ( "Executing" , CLJ_CMD , CLJ_ARGS . join ( " " ) , "in" , basePath ) ;
4959- const result = spawnSync ( CLJ_CMD , CLJ_ARGS , {
4959+ const result = safeSpawnSync ( CLJ_CMD , CLJ_ARGS , {
49604960 cwd : basePath ,
49614961 encoding : "utf-8" ,
49624962 timeout : TIMEOUT_MS ,
@@ -5339,7 +5339,7 @@ export async function createSwiftBom(path, options) {
53395339 `Executing '${ swiftCommand } ${ packageArgs . join ( " " ) } ' in ${ basePath } . Please wait ...` ,
53405340 ) ;
53415341 }
5342- const result = spawnSync ( swiftCommand , packageArgs , {
5342+ const result = safeSpawnSync ( swiftCommand , packageArgs , {
53435343 cwd : basePath ,
53445344 encoding : "utf-8" ,
53455345 timeout : TIMEOUT_MS ,
@@ -5923,7 +5923,7 @@ export function createPHPBom(path, options) {
59235923 if ( DEBUG_MODE ) {
59245924 console . log ( "About to invoke composer --version" ) ;
59255925 }
5926- const versionResult = spawnSync ( "composer" , [ "--version" ] , {
5926+ const versionResult = safeSpawnSync ( "composer" , [ "--version" ] , {
59275927 encoding : "utf-8" ,
59285928 } ) ;
59295929 if ( versionResult . status !== 0 || versionResult . error ) {
@@ -5956,7 +5956,7 @@ export function createPHPBom(path, options) {
59565956 console . log ( "Executing 'composer install' in" , basePath ) ;
59575957 args = [ "install" , "--ignore-platform-reqs" ] ;
59585958 }
5959- const result = spawnSync ( "composer" , args , {
5959+ const result = safeSpawnSync ( "composer" , args , {
59605960 cwd : basePath ,
59615961 encoding : "utf-8" ,
59625962 } ) ;
@@ -6108,7 +6108,7 @@ export async function createRubyBom(path, options) {
61086108 for ( const f of gemFiles ) {
61096109 const basePath = dirname ( f ) ;
61106110 console . log ( "Executing 'bundle install' in" , basePath ) ;
6111- const result = spawnSync ( "bundle" , [ "install" ] , {
6111+ const result = safeSpawnSync ( "bundle" , [ "install" ] , {
61126112 cwd : basePath ,
61136113 encoding : "utf-8" ,
61146114 } ) ;
@@ -6368,7 +6368,7 @@ export async function createCsharpBom(path, options) {
63686368 `Executing '${ buildCmd } ${ buildArgs . join ( " " ) } ' in ${ basePath } ` ,
63696369 ) ;
63706370 }
6371- const result = spawnSync ( buildCmd , buildArgs , {
6371+ const result = safeSpawnSync ( buildCmd , buildArgs , {
63726372 cwd : path ,
63736373 encoding : "utf-8" ,
63746374 env : { ...process . env , DOTNET_ROLL_FORWARD : "Major" } ,
0 commit comments