Skip to content

Commit

Permalink
Merge pull request #12 from danielgtaylor/master
Browse files Browse the repository at this point in the history
Implement basic CoffeeScript support
  • Loading branch information
pstadler committed Mar 21, 2014
2 parents 95c78ba + eda5e95 commit c68cf57
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ $ npm install -g flightplan
$ npm install flightplan --save-dev

# run a flightplan (`fly --help` for more information)
$ fly <destination> [--plan flightplan.js]
$ fly <destination> [--plan flightplan.(js|coffee)]
```

By default, the `fly` command will look for `flightplan.js` or `flightplan.coffee`.

If you do not install the Flightplan module locally to your project (i.e. to support non-javascript projects) then make sure the global `node_modules` is in your Node.js path. For example:

```bash
$ export NODE_PATH=/usr/local/lib/node_modules
$ fly <destination>
```

## Sample flightplan.js
Expand Down
25 changes: 23 additions & 2 deletions bin/fly.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,29 @@ program
var flightFile = path.join(process.cwd(), program.plan);

if(!fs.existsSync(flightFile)) {
logger.error(logger.format('Unable to load %s', program.plan.white));
process.exit(1);
if (program.plan === 'flightplan.js') {
// Maybe using CoffeeScript?
program.plan = 'flightplan.coffee';
flightFile = path.join(process.cwd(), program.plan);
if(!fs.existsSync(flightFile)) {
logger.error(logger.format('Unable to load %s (js/coffee)', 'flightplan'.white));
process.exit(1);
}
} else {
logger.error(logger.format('Unable to load %s', program.plan.white));
process.exit(1);
}
}

if (flightFile.indexOf('.coffee', flightFile.length - 7) !== -1) {
try {
// Register the CoffeeScript module loader
require('coffee-script/register');
} catch (err) {
logger.error(err);
logger.error(logger.format('Unable to load coffee-script for %s', program.plan.white));
process.exit(1);
}
}

var flightplan = require(flightFile)
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"prompt": "~0.2.12",
"pretty-hrtime": "^0.2.1"
},
"optionalDependencies": {
"coffee-script": "~1.7.1"
},
"devDependencies": {
"gulp": "~3.5.2",
"gulp-jshint": "~1.4.2",
Expand Down

0 comments on commit c68cf57

Please sign in to comment.