-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
42 lines (34 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
const fs = require('fs-extra');
const loader = require('js-yaml/lib/js-yaml/loader');
const read = function (filename, options) {
options = {
multi: false,
filename,
...options
};
return fs
.readFile(filename, 'utf8')
.then((string) => parseYaml(string, options));
};
read.sync = function (filename, options) {
options = {
multi: false,
filename,
...options
};
return parseYaml(fs.readFileSync(filename, 'utf8'), options);
};
function parseYaml(string, options) {
if (options.multi) {
return loader.safeLoadAll(string, options);
}
return loader.safeLoad(string, options);
}
read.YAMLException = require('js-yaml/lib/js-yaml/exception');
read.FAILSAFE_SCHEMA = require('js-yaml/lib/js-yaml/schema/failsafe');
read.JSON_SCHEMA = require('js-yaml/lib/js-yaml/schema/json');
read.CORE_SCHEMA = require('js-yaml/lib/js-yaml/schema/core');
read.DEFAULT_SAFE_SCHEMA = require('js-yaml/lib/js-yaml/schema/default_safe');
read.DEFAULT_FULL_SCHEMA = require('js-yaml/lib/js-yaml/schema/default_full');
module.exports = read;