Permalink
Browse files

Added subjake for forking other jakes.

Reviewed by me.
  • Loading branch information...
1 parent 53455d6 commit 9272316413b9730c40b1a4d155d157daa71a872d @tolmasky tolmasky committed Nov 2, 2009
Showing with 28 additions and 0 deletions.
  1. +28 −0 lib/jake.js
View
@@ -105,3 +105,31 @@ exports.FileList = require("jake/filelist").FileList;
application.original_dir
end
*/
+
+function serializeEnv(/*Object*/ env)
+{
+ var serialized = "";
+
+ for (variable in env)
+ if (env.hasOwnProperty(variable))
+ serialized += variable + "=\"" + env[variable] + "\" ";
+
+ return serialized;
+}
+
+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))
+ OS.exit(1);
+ }
+ });
+}

0 comments on commit 9272316

Please sign in to comment.