Permalink
Browse files

Cleaned up arguments escaping which was causing problems when buildin…

…g with Rhino. Bump to 0.1.3
  • Loading branch information...
Tom Robinson
Tom Robinson committed Mar 2, 2010
1 parent 83a3bb9 commit 5f52693735a50e73868265be6c7f9c8f50d152c3
Showing with 16 additions and 17 deletions.
  1. +15 −16 lib/jake.js
  2. +1 −1 package.json
View
@@ -22,14 +22,16 @@
// IN THE SOFTWARE.
//
-var FILE = require("file"),
- SYSTEM = require("system"),
+var FILE = require("file");
+var SYSTEM = require("system");
+var UTIL = require("util");
+var OS = require("os");
- Task = require("jake/task").Task,
- FileTask = require("jake/filetask").FileTask,
- FileCreationTask = require("jake/filecreationtask").FileCreationTask,
- TaskManager = require("jake/taskmanager").TaskManager,
- Application = require("jake/application").Application;
+var Task = require("jake/task").Task;
+var FileTask = require("jake/filetask").FileTask;
+var FileCreationTask = require("jake/filecreationtask").FileCreationTask;
+var TaskManager = require("jake/taskmanager").TaskManager;
+var Application = require("jake/application").Application;
// Exports
exports.Task = Task;
@@ -106,29 +108,26 @@ exports.FileList = require("jake/filelist").FileList;
end
*/
+// record the initial SYSTEM.env so we know what needs to be serialized later
+var envInitial = Object.freeze(UTIL.copy(SYSTEM.env));
function serializeEnv(/*Object*/ env)
{
- var serialized = "";
-
- for (variable in env)
- if (env.hasOwnProperty(variable))
- serialized += variable + "=\"" + env[variable] + "\" ";
-
- return serialized;
+ return Object.keys(env).map(function(key) {
+ return (env[key] !== envInitial[key]) ? key + "=" + OS.enquote(env[key]) : null;
+ }).filter(function(x) { return !!x; }).join(" ");
}
exports.subjake = function(/*Array<String> | String*/ directories, /*String*/ aTaskName, /*Object*/ env)
{
if (!Array.isArray(directories))
directories = [directories];
- var OS = require("os");
directories.forEach(function(/*String*/ aDirectory)
{
if (FILE.isDirectory(aDirectory))
{
- if (OS.system("cd " + aDirectory + " && " + serializeEnv(env) + " jake " + aTaskName))
+ if (OS.system("cd " + OS.enquote(aDirectory) + " && " + serializeEnv(env) + " jake " + OS.enquote(aTaskName)))
OS.exit(1);
}
});
View
@@ -3,5 +3,5 @@
"author": "Francisco Tolmasky (http://tolmasky.com/)",
"description": "A build system for CommonJS, lifted from Rake",
"keywords": ["build", "jake", "rake", "make"],
- "version":"0.1.2"
+ "version":"0.1.3"
}

0 comments on commit 5f52693

Please sign in to comment.