From 8a13e9489b14777a8d63b92e95fbf429a8738a06 Mon Sep 17 00:00:00 2001 From: Veselin Todorov Date: Sun, 12 Feb 2012 22:52:38 +0200 Subject: [PATCH] `Program` can handle local paths now. --- lib/program.js | 7 +++++-- test/program.test.js | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/program.js b/lib/program.js index 8793b33..58f2d35 100644 --- a/lib/program.js +++ b/lib/program.js @@ -38,7 +38,7 @@ Program.prototype.file = function() { * @api public */ Program.prototype.exec = function() { - return this._ext === '.js' ? 'node' : 'coffee'; + return this._ext !== '.js' ? 'coffee' : 'node'; }; /** @@ -58,7 +58,10 @@ Program.prototype.path = function() { * @api public */ Program.prototype.exists = function() { - return path.existsSync(this._full); + return path.existsSync(this._full) + || path.existsSync(this._full + '.js') + || path.existsSync(this._full + '.coffee') + || path.existsSync(path.join(process.cwd(), this._full)); }; /** diff --git a/test/program.test.js b/test/program.test.js index 83f939f..09a93f5 100644 --- a/test/program.test.js +++ b/test/program.test.js @@ -50,6 +50,12 @@ describe('Program', function() { var program = new Program(path.join(__dirname, 'app.test.js')); program.exists().should.be.true; + + var program = new Program('test/support/whiny.js'); + program.exists().should.be.true; + + var program = new Program('test/support/whiny'); + program.exists().should.be.true; }); }); });