Permalink
Browse files

feat(config): better error when Coffee/Live Script not installed

  • Loading branch information...
1 parent af2d0e7 commit aca84dc9c6f4a966280bfcd080317c7c9d498f53 @vojtajina vojtajina committed Feb 5, 2014
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/config.js
View
@@ -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) {
@@ -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);
}

0 comments on commit aca84dc

Please sign in to comment.