Skip to content
Browse files

feat: support LiveScript configuration

  • Loading branch information...
1 parent df557ce commit 88deebe74a0b6f01e23f3ceefea5811183218600 @czchen czchen committed with vojtajina Dec 24, 2013
Showing with 95 additions and 2 deletions.
  1. +68 −0 config.tpl.ls
  2. +5 −0 lib/config.js
  3. +20 −1 lib/init/formatters.js
  4. +2 −1 package.json
View
68 config.tpl.ls
@@ -0,0 +1,68 @@
+# Karma configuration
+# Generated on %DATE%
+
+module.exports = (config) ->
+ config.set do
+
+ # base path that will be used to resolve all patterns (eg. files, exclude)
+ basePath: '%BASE_PATH%'
+
+
+ # frameworks to use
+ # available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+ frameworks: [%FRAMEWORKS%]
+
+
+ # list of files / patterns to load in the browser
+ files: [
+ %FILES%
+ ]
+
+
+ # list of files to exclude
+ exclude: [
+ %EXCLUDE%
+ ]
+
+
+ # preprocess matching files before serving them to the browser
+ # available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+ preprocessors: %PREPROCESSORS%
+
+
+ # test results reporter to use
+ # possible values: 'dots', 'progress'
+ # available reporters: https://npmjs.org/browse/keyword/karma-reporter
+ reporters: ['progress']
+
+
+ # web server port
+ port: 9876
+
+
+ # enable / disable colors in the output (reporters and logs)
+ colors: true
+
+
+ # level of logging
+ # possible values:
+ # - config.LOG_DISABLE
+ # - config.LOG_ERROR
+ # - config.LOG_WARN
+ # - config.LOG_INFO
+ # - config.LOG_DEBUG
+ logLevel: config.LOG_INFO
+
+
+ # enable / disable watching file and executing tests whenever any file changes
+ autoWatch: %AUTO_WATCH%
+
+
+ # satart these browsers
+ # available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+ browsers: [%BROWSERS%]
+
+
+ # Continuous Integration mode
+ # if true, Karma captures browsers, runs the tests and exits
+ singleRun: false
View
5 lib/config.js
@@ -9,6 +9,11 @@ var constant = require('./constants');
// It's not directly used in this file.
require('coffee-script');
+// LiveScript is required here to enable config files written in LiveScript.
+// It's not directly used in this file.
+try {
+ require('LiveScript');
+} catch (e) {}
var Pattern = function(pattern, served, included, watched) {
this.pattern = pattern;
View
21 lib/init/formatters.js
@@ -4,12 +4,17 @@ var util = require('util');
var JS_TEMPLATE_PATH = __dirname + '/../../config.tpl.js';
var COFFEE_TEMPLATE_PATH = __dirname + '/../../config.tpl.coffee';
var COFFEE_REGEXP = /\.coffee$/;
+var LIVE_TEMPLATE_PATH = __dirname + '/../../config.tpl.ls';
+var LIVE_REGEXP = /\.ls$/;
var isCoffeeFile = function(filename) {
return COFFEE_REGEXP.test(filename);
};
+var isLiveFile = function(filename) {
+ return LIVE_REGEXP.test(filename);
+};
var JavaScriptFormatter = function() {
@@ -87,10 +92,24 @@ var CoffeeFormatter = function() {
this.TEMPLATE_FILE_PATH = COFFEE_TEMPLATE_PATH;
};
+var LiveFormatter = function() {
+ JavaScriptFormatter.call(this);
+
+ this.TEMPLATE_FILE_PATH = LIVE_TEMPLATE_PATH;
+};
exports.JavaScript = JavaScriptFormatter;
exports.Coffee = CoffeeFormatter;
+exports.Live = LiveFormatter;
exports.createForPath = function(path) {
- return isCoffeeFile(path) ? new CoffeeFormatter() : new JavaScriptFormatter();
+ if (isCoffeeFile(path)) {
+ return new CoffeeFormatter();
+ }
+
+ if (isLiveFile(path)) {
+ return new LiveFormatter();
+ }
+
+ return new JavaScriptFormatter();
};
View
3 package.json
@@ -157,7 +157,8 @@
"karma-ng-scenario": "*",
"karma-coffee-preprocessor": "*",
"karma-html2js-preprocessor": "*",
- "karma-browserstack-launcher": "*"
+ "karma-browserstack-launcher": "*",
+ "LiveScript": "~1.2.0"
},
"main": "./lib/index",
"bin": {},

0 comments on commit 88deebe

Please sign in to comment.
Something went wrong with that request. Please try again.