Skip to content

Commit 9fb080b

Browse files
NathanHowellalexeagle
authored andcommitted
Replace grep with bash's regex operator
1 parent 8854bfd commit 9fb080b

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

internal/node/node_patches.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,9 @@ set Path=${nodeDir};%Path%
563563
}
564564
else {
565565
fs$1.writeFileSync(path.join(nodeDir, 'node'), `#!/bin/bash
566-
export NP_PATCHED_NODEJS=${nodeDir}
567-
export PATH=${nodeDir}:$PATH
568-
hasScript=\`echo "$@" | grep ${path.basename(requireScriptName)}\`
569-
if [ "$hasScript"=="" ]; then
566+
export NP_PATCHED_NODEJS="${nodeDir}"
567+
export PATH="${nodeDir}":\$PATH
568+
if [[ ! "\${@}" =~ "${file}" ]]; then
570569
exec ${process.execPath} --require "${requireScriptName}" "$@"
571570
else
572571
exec ${process.execPath} "$@"

packages/node-patches/src/subprocess.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ set Path=${nodeDir};%Path%
2828
} else {
2929
fs.writeFileSync(
3030
path.join(nodeDir, 'node'), `#!/bin/bash
31-
export NP_PATCHED_NODEJS=${nodeDir}
32-
export PATH=${nodeDir}:$PATH
33-
hasScript=\`echo "$@" | grep ${path.basename(requireScriptName)}\`
34-
if [ "$hasScript"=="" ]; then
31+
export NP_PATCHED_NODEJS="${nodeDir}"
32+
export PATH="${nodeDir}":\$PATH
33+
if [[ ! "\${@}" =~ "${file}" ]]; then
3534
exec ${process.execPath} --require "${requireScriptName}" "$@"
3635
else
3736
exec ${process.execPath} "$@"

0 commit comments

Comments
 (0)