Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save c4milo/551467 to your computer and use it in GitHub Desktop.
Save c4milo/551467 to your computer and use it in GitHub Desktop.
diff --git a/lib/jake.js b/lib/jake.js
index ee15998..60dd85d 100644
--- a/lib/jake.js
+++ b/lib/jake.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
/*
- * Node-Jake JavaScript build tool
+ * Node-Jake JavaScript build tool
* Copyright 2112 Matthew Eernisse (mde@fleegix.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,7 +41,7 @@ var usage = ''
var parseopts = new function () {
var optsReg = {
directory: ['-C', '--directory']
- , jakefile: ['-f', '--file']
+ , jakefile: ['-f', '--jakefile']
, tasks: ['-T', '--tasks']
, help: ['-h', '--help']
, version: ['-V', '--version']
@@ -92,7 +92,7 @@ var parseopts = new function () {
cmds.push(arg);
}
}
-
+
return {cmds: cmds, opts: opts};
};
@@ -129,7 +129,7 @@ var jake = new function () {
nsName = 'default';
taskName = name;
}
-
+
var task = jake.namespaceTasks[nsName][taskName];
if (!task) {
throw new Error('Task "' + name + '" is not defined in the Jakefile.');
@@ -138,7 +138,7 @@ var jake = new function () {
};
this.runTask = function (name, args) {
var jake = this;
-
+
var task = this.getTask(name);
var deps = task.deps;
if (deps && deps instanceof Array) {
@@ -153,13 +153,13 @@ var jake = new function () {
}
return;
}
-
+
var async = false;
do {
if (!deps.length) {
return runDependencies();
}
-
+
var depName = deps.shift();
jake.runTask.call(jake, depName, args);
async = jake.getTask(depName).async;
@@ -169,7 +169,7 @@ var jake = new function () {
} else {
_doRunTask();
}
-
+
function _doRunTask () {
var parsed = jake.parseArgs(args);
var passArgs = parsed.cmds;
@@ -197,7 +197,7 @@ var jake = new function () {
}
}
if (!hasOpts) { opts = null; }
- return {cmds: cmds, opts: opts};
+ return {cmds: cmds, opts: opts};
};
this.die = function (str) {
@@ -270,11 +270,9 @@ if (typeof opts.version != 'undefined') {
jake.die(JAKE_VERSION);
}
-try {
- var stats = fs.statSync(jakefile + '.js');
-}
-catch (e) {
- jake.die('Could not load Jakefile.\nIf no Jakefile specified with -f or --jakefile, jake looks for Jakefile.js in the current directory.');
+var exists = path.existsSync(jakefile + '.js') || path.existsSync(jakefile);
+if(!exists) {
+ jake.die('Could not load Jakefile.\nIf no Jakefile specified with -f or --jakefile, jake looks for Jakefile.js or Jakefile in the current directory.');
}
try {
@@ -291,3 +289,4 @@ else {
process.chdir(dirname);
jake.runTask(taskName, cmds);
}
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment