Comparing version
module.exports = function (cow, variables) { | ||
var eyes = escapeRe(variables.eyes); | ||
var tongue = escapeRe(variables.tongue); | ||
if (cow.indexOf("$the_cow") !== -1) { | ||
@@ -8,7 +11,23 @@ cow = extractTheCow(cow); | ||
.replace(/\$thoughts/g, variables.thoughts) | ||
.replace(/\$eyes/g, variables.eyes) | ||
.replace(/\$tongue/g, variables.tongue) | ||
.replace(/\$\{eyes\}/g, variables.eyes) | ||
.replace(/\$\{tongue\}/g, variables.tongue) | ||
.replace(/\$eyes/g, eyes) | ||
.replace(/\$tongue/g, tongue) | ||
.replace(/\$\{eyes\}/g, eyes) | ||
.replace(/\$\{tongue\}/g, tongue) | ||
; | ||
}; | ||
/* | ||
* "$" dollar signs must be doubled before being used in a regex replace | ||
* This can occur in eyes or tongue. | ||
* For example: | ||
* | ||
* cowsay -g Moo! | ||
* | ||
* cowsay -e "\$\$" Moo! | ||
*/ | ||
function escapeRe (s) { | ||
if (s && s.replace) { | ||
return s.replace(/\$/g, "$$$$"); | ||
} | ||
return s; | ||
} | ||
@@ -15,0 +34,0 @@ |
{ | ||
"name": "cowsay", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "cowsay is a configurable talking cow", | ||
@@ -32,9 +32,8 @@ "keywords": [ | ||
"dependencies": { | ||
"get-stdin": "^4.0.1", | ||
"optimist": "~0.3.5" | ||
"optimist": "~0.6.1" | ||
}, | ||
"devDependencies": { | ||
"nodeunit": "~0.7.4" | ||
"nodeunit": "~0.9.1" | ||
}, | ||
"preferGlobal": true | ||
} |
Sorry, the diff of this file is not supported yet
34996
2.68%1
-50%62
1.64%408
4.35%+ Added
+ Added
- Removed
- Removed
- Removed
Updated