Skip to content

Commit 54af127

Browse files
Removed the external-facing YAML object. All methods will now allow a YAML string to be passed-in instead
1 parent a5ac37e commit 54af127

File tree

6 files changed

+18
-307
lines changed

6 files changed

+18
-307
lines changed

docs/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ Classes & Methods
2727
- [`get()`](refs.md#getref-options)
2828
- [`set()`](refs.md#setref-value-options)
2929

30-
#### [`YAML`](yaml.md)
31-
- [`parse()`](yaml.md#parsetext)
32-
- [`stringify()`](yaml.md#stringifyvalue)
33-
3430
#### [`Options`](options.md)
3531

3632

docs/yaml.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

lib/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ var Promise = require('./util/promise'),
1212
ono = require('ono');
1313

1414
module.exports = $RefParser;
15-
module.exports.YAML = require('./util/yaml');
1615

1716
/**
1817
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,

lib/parsers/yaml.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

3-
var Promise = require('../util/promise'),
4-
YAML = require('../util/yaml');
3+
var Promise = require('../util/promise');
4+
var yaml = require('js-yaml');
5+
var ono = require('ono');
56

67
module.exports = {
78
/**
@@ -38,14 +39,28 @@ module.exports = {
3839
* @returns {Promise}
3940
*/
4041
parse: function parseYAML(file) {
42+
var parsed;
43+
4144
return new Promise(function(resolve, reject) {
4245
var data = file.data;
4346
if (Buffer.isBuffer(data)) {
4447
data = data.toString();
4548
}
4649

4750
if (typeof data === 'string') {
48-
resolve(YAML.parse(data));
51+
try {
52+
parsed = yaml.safeLoad(data);
53+
}
54+
catch (e) {
55+
if (e instanceof Error) {
56+
throw e;
57+
}
58+
else {
59+
// https://github.com/nodeca/js-yaml/issues/153
60+
throw ono(e, e.message);
61+
}
62+
}
63+
resolve(parsed);
4964
}
5065
else {
5166
// data is already a JavaScript value (object, array, number, null, NaN, etc.)

lib/util/yaml.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

test/specs/yaml.spec.js

Lines changed: 0 additions & 159 deletions
This file was deleted.

0 commit comments

Comments
 (0)