manis
Advanced tools
Comparing version 0.2.3 to 0.3.0-beta.1
@@ -51,5 +51,3 @@ /** | ||
init: function () { | ||
this.loader = this.loader || function (text) { | ||
return JSON.parse(text); | ||
}; | ||
this.loader = this.loader || util.loader; | ||
@@ -56,0 +54,0 @@ this.cached = this.cache && Object.create(null); |
@@ -274,2 +274,6 @@ /** | ||
Manis.yaml = require('js-yaml'); | ||
Manis.loader = util.loader; | ||
module.exports = Manis; |
@@ -116,1 +116,21 @@ /** | ||
exports.homeDirectory = exports.getHome(); | ||
var yaml = require('js-yaml'); | ||
var stripJSONComment = require('strip-json-comments'); | ||
/** | ||
* Default loader | ||
* | ||
* @param {string} content string to be parsed | ||
* @param {string} path config file path | ||
* @param {?Object} options options for yaml.safeLoad | ||
* @return {Object} | ||
*/ | ||
exports.loader = function (content, path, options) { | ||
try { | ||
return yaml.safeLoad(stripJSONComment(content), options || {filename: path, json: true}); | ||
} | ||
catch (e) { | ||
return {}; | ||
} | ||
}; |
{ | ||
"name": "manis", | ||
"version": "0.2.3", | ||
"version": "0.3.0-beta.1", | ||
"description": "Find and read your configuration files recursively", | ||
@@ -38,3 +38,7 @@ "main": "lib/manis.js", | ||
"mock-fs": "^3.0.0" | ||
}, | ||
"dependencies": { | ||
"js-yaml": "^3.5.1", | ||
"strip-json-comments": "^2.0.0" | ||
} | ||
} |
@@ -57,2 +57,4 @@ Manis | ||
#### NOTICE: the default loader strip comment after manis@0.3.0. | ||
### Loading `.yml` with `js-yaml` | ||
@@ -76,3 +78,5 @@ | ||
#### NOTICE: the default loader used `js-yaml` to load YAML and JSON content after manis@0.3.0. | ||
### With defaults | ||
@@ -167,2 +171,13 @@ | ||
### Manis.yaml; | ||
Alias for `js-yaml` module. | ||
### Object Manis.loader; | ||
The default loader, parse JSON or YAML content with `js-yaml`. | ||
### Object Manis#from(string path); | ||
#### options | ||
@@ -169,0 +184,0 @@ |
21371
497
209
2
+ Addedjs-yaml@^3.5.1
+ Addedstrip-json-comments@^2.0.0
+ Addedargparse@1.0.10(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)