Skip to content

Commit 0a351e9

Browse files
committed
chore: add some comments and docs
1 parent 7963ab5 commit 0a351e9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: README.md

+11
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,14 @@ Functionally, this means:
147147
hook scripts, then they can override the default package script with an
148148
explicit `cmd` option pointing to the `node_modules/.hook/${event}`
149149
script.
150+
151+
## Escaping
152+
153+
In order to ensure that arguments are handled consistently, this module
154+
writes a temporary script file containing the command as it exists in
155+
the package.json, followed by the user supplied arguments having been
156+
escaped to ensure they are processed as literal strings. We then instruct
157+
the shell to execute the script file, and when the process exits we remove
158+
the temporary file.
159+
160+
The actual implementation of the escaping is in `lib/escape.js`.

Diff for: lib/escape.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
// eslint-disable-next-line max-len
4+
// this code adapted from: https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
35
const cmd = (input) => {
46
if (!input.length) {
57
return '""'

0 commit comments

Comments
 (0)