Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement JSON config file support

Supporting JSON is nice for people who are familiar with it. It's also nice if you want to pass in JavaScript objects as options
  • Loading branch information...
commit 05a0d134c32b53050878374f34d9c07d922ae722 1 parent e6bc272
@Raynos Raynos authored committed
View
3  examples/custom_adapter/testem.json
@@ -0,0 +1,3 @@
+{
+ "framework": "custom"
+}
View
1  examples/custom_adapter/testem.yml
@@ -1 +0,0 @@
-framework: custom
View
3  examples/mocha_simple/testem.json
@@ -0,0 +1,3 @@
+{
+ "framework": "mocha"
+}
View
1  examples/mocha_simple/testem.yml
@@ -1 +0,0 @@
-framework: mocha
View
17 lib/config.js
@@ -18,11 +18,20 @@ function Config(progOptions){
Config.prototype.read = function(callback){
var configFile = this.progOptions.file
, self = this
- fs.readFile(configFile, function(err, data){
- if (!err){
- var cfg = yaml.load(String(data))
- self.config = cfg
+ , jsonConfigFile = configFile.replace(/\.yml$/, ".json")
+
+ fs.readFile(configFile, function (err, data) {
+ if (err) {
+ return fs.readFile(jsonConfigFile, function (err, data) {
+ if (!err) {
+ var cfg = JSON.parse(data.toString())
+ self.config = cfg
+ }
+ if (callback) callback.call(self)
+ })
}
+ var cfg = yaml.load(String(data))
+ self.config = cfg
if (callback) callback.call(self)
})
}
Please sign in to comment.
Something went wrong with that request. Please try again.