Skip to content

Commit

Permalink
Added handling of Jakefile along with Jakefile.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ukstv authored and mde committed Aug 26, 2010
1 parent b4ac596 commit 84bb0c2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/jake.js
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand Down

7 comments on commit 84bb0c2

@c4milo
Copy link

@c4milo c4milo commented on 84bb0c2 Aug 26, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

@ukstv ukstv commented on 84bb0c2 Aug 27, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mde
Copy link
Contributor

@mde mde commented on 84bb0c2 Aug 29, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@mde mde commented on 84bb0c2 Aug 29, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@c4milo
Copy link

@c4milo c4milo commented on 84bb0c2 Aug 29, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mde
Copy link
Contributor

@mde mde commented on 84bb0c2 Aug 29, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@c4milo
Copy link

@c4milo c4milo commented on 84bb0c2 Aug 30, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahaha who knows

Please sign in to comment.