[Pkg-javascript-commits] [node-shell-quote] 19/137: factor out interpolation
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Aug 25 19:19:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-shell-quote.
commit 1b21b018e01392d2c74e53136f8fa0ca838d7643
Author: James Halliday <mail at substack.net>
Date: Sun Apr 14 20:10:25 2013 -0700
factor out interpolation
---
index.js | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/index.js b/index.js
index 8a71346..c22cc6d 100644
--- a/index.js
+++ b/index.js
@@ -23,23 +23,21 @@ exports.parse = function (s, env) {
;
}
else if (/^"/.test(s)) {
- return s
- .replace(/^"|"$/g, '')
- .replace(/\\(["'\\$`(){}!#&*|])/g, '$1')
- .replace(/\$(\w+)/g, getVar)
- .replace(/\${(\w+)}/g, getVar)
- ;
- }
- else {
- return s
- .replace(/\\([ "'\\$`(){}!#&*|])/g, '$1')
- .replace(/\$(\w+)/g, getVar)
- .replace(/\${(\w+)}/g, getVar)
- ;
+ return interpolate(s.replace(/^"|"$/g, ''))
}
+ else return interpolate(s);
})
;
+
function getVar (_, x) {
return String(env[x])
}
+
+ function interpolate (s) {
+ return s
+ .replace(/\\([ "'\\$`(){}!#&*|])/g, '$1')
+ .replace(/\$(\w+)/g, getVar)
+ .replace(/\${(\w+)}/g, getVar)
+ ;
+ }
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-shell-quote.git
More information about the Pkg-javascript-commits
mailing list