diff options
author | isaacs <i@izs.me> | 2020-11-19 22:30:40 +0300 |
---|---|---|
committer | Darcy Clarke <darcy@darcyclarke.me> | 2020-12-03 00:26:52 +0300 |
commit | 15d7333f832e3d68ae16895569f27a27ef86573e (patch) | |
tree | 32bca58d2ded2fe16e981530a7474ae14a0b00a0 /lib/utils | |
parent | e9a440bcc5bd9a42dbdbf4bf9340d188c910857c (diff) |
Use @npmcli/run-script for exec, explore; add interactive exec
This removes all other arg/shell escaping mechanisms, as they are no
longer needed, and will be un-done by puka in @npmcli/run-script anyway.
Adds an interactive shell mode when `npm exec` is run without any
arguments, allowing users to interactively test out commands in an npm
script environment. Previously, this would do nothing, and just exit.
Prevent weird behavior from `npm explore ../blah`. `explore` now can
_only_ be used to explore packages that are actually found in the
relevant `node_modules` folder.
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/escape-arg.js | 18 | ||||
-rw-r--r-- | lib/utils/escape-exec-path.js | 21 |
2 files changed, 0 insertions, 39 deletions
diff --git a/lib/utils/escape-arg.js b/lib/utils/escape-arg.js deleted file mode 100644 index 135d380fc..000000000 --- a/lib/utils/escape-arg.js +++ /dev/null @@ -1,18 +0,0 @@ -const { normalize } = require('path') -const isWindows = require('./is-windows.js') - -/* -Escape the name of an executable suitable for passing to the system shell. - -Windows is easy, wrap in double quotes and you're done, as there's no -facility to create files with quotes in their names. - -Unix-likes are a little more complicated, wrap in single quotes and escape -any single quotes in the filename. The '"'"' construction ends the quoted -block, creates a new " quoted string with ' in it. So, `foo'bar` becomes -`'foo'"'"'bar'`, which is the bash way of saying `'foo' + "'" + 'bar'`. -*/ - -module.exports = str => isWindows ? '"' + normalize(str) + '"' - : /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, '\'"\'"\'') + "'" - : str diff --git a/lib/utils/escape-exec-path.js b/lib/utils/escape-exec-path.js deleted file mode 100644 index 83c70680b..000000000 --- a/lib/utils/escape-exec-path.js +++ /dev/null @@ -1,21 +0,0 @@ -const { normalize } = require('path') -const isWindows = require('./is-windows.js') - -/* -Escape the name of an executable suitable for passing to the system shell. - -Windows is easy, wrap in double quotes and you're done, as there's no -facility to create files with quotes in their names. - -Unix-likes are a little more complicated, wrap in single quotes and escape -any single quotes in the filename. The '"'"' construction ends the quoted -block, creates a new " quoted string with ' in it. So, `foo'bar` becomes -`'foo'"'"'bar'`, which is the bash way of saying `'foo' + "'" + 'bar'`. -*/ - -const winQuote = str => !/ /.test(str) ? str : '"' + str + '"' -const winEsc = str => normalize(str).split(/\\/).map(winQuote).join('\\') - -module.exports = str => isWindows ? winEsc(str) - : /[^-_.~/\w]/.test(str) ? "'" + str.replace(/'/g, '\'"\'"\'') + "'" - : str |