Skip to content

Commit

Permalink
feat(config): better error when Coffee/Live Script not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Feb 5, 2014
1 parent af2d0e7 commit aca84dc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ var log = logger.create('config');
var helper = require('./helper');
var constant = require('./constants');

var COFFEE_SCRIPT_AVAILABLE = false;
var LIVE_SCRIPT_AVAILABLE = false;

// Coffee is required here to enable config files written in coffee-script.
// It's not directly used in this file.
try {
require('coffee-script').register();
COFFEE_SCRIPT_AVAILABLE = true;
} catch (e) {}

// LiveScript is required here to enable config files written in LiveScript.
// It's not directly used in this file.
try {
require('LiveScript');
LIVE_SCRIPT_AVAILABLE = true;
} catch (e) {}

var Pattern = function(pattern, served, included, watched) {
Expand Down Expand Up @@ -244,6 +249,15 @@ var parseConfig = function(configFilePath, cliOptions) {
log.error('File %s does not exist!', configFilePath);
} else {
log.error('Invalid config file!\n ' + e.stack);

var extension = path.extname(configFilePath);
if (extension === '.coffee' && !COFFEE_SCRIPT_AVAILABLE) {
log.error('You need to install CoffeeScript.\n' +
' npm install coffee-script --save-dev');
} else if (extension === '.ls' && !LIVE_SCRIPT_AVAILABLE) {
log.error('You need to install LiveScript.\n' +
' npm install LiveScript --save-dev');
}
}
return process.exit(1);
}
Expand Down

0 comments on commit aca84dc

Please sign in to comment.