diff --git a/internal/node/node_patches.js b/internal/node/node_patches.js index 3d062b296a..d7273adcd2 100644 --- a/internal/node/node_patches.js +++ b/internal/node/node_patches.js @@ -563,10 +563,9 @@ set Path=${nodeDir};%Path% } else { fs$1.writeFileSync(path.join(nodeDir, 'node'), `#!/bin/bash -export NP_PATCHED_NODEJS=${nodeDir} -export PATH=${nodeDir}:$PATH -hasScript=\`echo "$@" | grep ${path.basename(requireScriptName)}\` -if [ "$hasScript"=="" ]; then +export NP_PATCHED_NODEJS="${nodeDir}" +export PATH="${nodeDir}":\$PATH +if [[ ! "\${@}" =~ "${file}" ]]; then exec ${process.execPath} --require "${requireScriptName}" "$@" else exec ${process.execPath} "$@" diff --git a/packages/node-patches/src/subprocess.ts b/packages/node-patches/src/subprocess.ts index 4619a526cf..892a0a23b9 100644 --- a/packages/node-patches/src/subprocess.ts +++ b/packages/node-patches/src/subprocess.ts @@ -28,10 +28,9 @@ set Path=${nodeDir};%Path% } else { fs.writeFileSync( path.join(nodeDir, 'node'), `#!/bin/bash -export NP_PATCHED_NODEJS=${nodeDir} -export PATH=${nodeDir}:$PATH -hasScript=\`echo "$@" | grep ${path.basename(requireScriptName)}\` -if [ "$hasScript"=="" ]; then +export NP_PATCHED_NODEJS="${nodeDir}" +export PATH="${nodeDir}":\$PATH +if [[ ! "\${@}" =~ "${file}" ]]; then exec ${process.execPath} --require "${requireScriptName}" "$@" else exec ${process.execPath} "$@"