Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added handling of Jakefile along with Jakefile.js

  • Loading branch information...
commit 84bb0c25fa4c5bd2aee106c363a5c2e43228e1c2 1 parent b4ac596
@ukstv ukstv authored mde committed
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/jake.js
View
11 lib/jake.js
@@ -26,7 +26,7 @@ var JAKE_VERSION = '0.1.5'
var usage = ''
+ 'Node-Jake JavaScript build tool\n'
+ '********************************************************************************\n'
- + 'If no flags are given, Node-Jake looks for a Jakefile.js in the current directory.\n'
+ + 'If no flags are given, Node-Jake looks for a Jakefile or Jakefile.js in the current directory.\n'
+ '********************************************************************************\n'
+ '{Usage}: jake [options] target (commands/options ...)\n'
+ '\n'
@@ -284,10 +284,15 @@ if (typeof opts.version != 'undefined') {
}
try {
- var stats = fs.statSync(jakefile + '.js');
+ try{
+ var stats = fs.statSync(jakefile + '.js');
+ }
+ catch (e) {
+ var stats = fs.statSync(jakefile);
+ }
}
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.');
+ jake.die('Could not load Jakefile.\nIf no Jakefile specified with -f or --jakefile, jake looks for Jakefile or Jakefile.js in the current directory.');
}
try {

7 comments on commit 84bb0c2

@c4milo

it could be simply

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.');
}

@ukstv

Mea culpa, I have not grokked node API completely yet.

@mde
Owner

We're all learning the API. :) I didn't get what c4milo was doing with this when I was comparing the two different sets. I'll update the code to use path.existsSync. Very nice!

@mde
Owner

Oh, I see, the sync version is undocumented. Still seems like a good improvement.

@c4milo

yeah, it's embarrassing. There are still some functions undocumented in nodejs

@mde
Owner

It's possible this is deliberately undocumented, being a sync call. :)

@c4milo

ahaha who knows

Please sign in to comment.
Something went wrong with that request. Please try again.