diff --git a/config.tpl.coffee b/config.tpl.coffee new file mode 100644 index 000000000..152007097 --- /dev/null +++ b/config.tpl.coffee @@ -0,0 +1,58 @@ +# Karma configuration +# Generated on %DATE% + +module.exports = (karma) -> + karma.configure + + # base path, that will be used to resolve all patterns, eg. files, exclude + basePath: '%BASE_PATH%' + + # frameworks to use + frameworks: [%FRAMEWORKS%] + + # list of files / patterns to load in the browser + files: [ + %FILES% + ] + + # list of files to exclude + exclude: [ + %EXCLUDE% + ] + + # test results reporter to use + # possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' + reporters: ['progress'] + + # web server port + port: 9876 + + # cli runner port + runnerPort: 9100 + + # enable / disable colors in the output (reporters and logs) + colors: true + + # level of logging + # possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG + logLevel: karma.LOG_INFO + + # enable / disable watching file and executing tests whenever any file changes + autoWatch: %AUTO_WATCH% + + # Start these browsers, currently available: + # - Chrome + # - ChromeCanary + # - Firefox + # - Opera + # - Safari (only Mac) + # - PhantomJS + # - IE (only Windows) + browsers: [%BROWSERS%] + + # If browser does not capture in given timeout [ms], kill it + captureTimeout: 60000 + + # Continuous Integration mode + # if true, it capture browsers, run tests and exit + singleRun: false diff --git a/config.template b/config.tpl.js similarity index 100% rename from config.template rename to config.tpl.js diff --git a/lib/init.js b/lib/init.js index 881eafe78..6b51d16ca 100755 --- a/lib/init.js +++ b/lib/init.js @@ -1,5 +1,3 @@ -// TODO(vojta): generate coffee syntax - var readline = require('readline'); var fs = require('fs'); var util = require('util'); @@ -12,7 +10,8 @@ var constant = require('./constants'); var log = logger.create('init'); -var CONFIG_TPL_PATH = __dirname + '/../config.template'; +var JS_TPL_PATH = __dirname + '/../config.tpl.js'; +var COFFEE_TPL_PATH = __dirname + '/../config.tpl.coffee'; var COLORS_ON = { @@ -315,6 +314,11 @@ var getReplacementsFromAnswers = function(answers, basePath) { }; +var isCoffeeFile = function(filename) { + return /\.coffee$/.test(filename); +}; + + exports.init = function(config) { var useColors = true; var logLevel = constant.LOG_INFO; @@ -344,8 +348,9 @@ exports.init = function(config) { sm.process(questions, function(answers) { var cwd = process.cwd(); var configFile = config.configFile; + var templateFile = isCoffeeFile(configFile) ? COFFEE_TPL_PATH : JS_TPL_PATH; var replacements = getReplacementsFromAnswers(answers, getBasePath(configFile, process.cwd())); - var content = fs.readFileSync(CONFIG_TPL_PATH).toString().replace(/%(.*)%/g, function(a, key) { + var content = fs.readFileSync(templateFile).toString().replace(/%(.*)%/g, function(a, key) { return replacements[key]; });