[Pkg-javascript-commits] [node-shell-quote] 18/137: half the env tests are working with basic 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 589147176be93834bad7fcee83bd255e35c14adc
Author: James Halliday <mail at substack.net>
Date: Sun Apr 14 20:08:26 2013 -0700
half the env tests are working with basic interpolation
---
index.js | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/index.js b/index.js
index d18d614..8a71346 100644
--- a/index.js
+++ b/index.js
@@ -12,22 +12,34 @@ exports.quote = function (xs) {
}).join(' ');
};
-exports.parse = function (s) {
+exports.parse = function (s, env) {
+ if (!env) env = {};
return s.match(/(['"])((\\\1|[^\1])*?)\1|(\\ |\S)+/g)
.map(function (s) {
if (/^'/.test(s)) {
return s
.replace(/^'|'$/g, '')
- .replace(/\\(["'\\$`(){}!#&*|])/g, '$1');
+ .replace(/\\(["'\\$`(){}!#&*|])/g, '$1')
;
}
else if (/^"/.test(s)) {
return s
.replace(/^"|"$/g, '')
- .replace(/\\(["'\\$`(){}!#&*|])/g, '$1');
+ .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)
;
}
- else return s.replace(/\\([ "'\\$`(){}!#&*|])/g, '$1');
})
;
+ function getVar (_, x) {
+ return String(env[x])
+ }
};
--
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