Skip to content

Commit 0e2a879

Browse files
committed
js-yaml is mostly dead although it did get a CVE patch to address
the issue that got it put onto a watch list. 'yaml' is no longer TJ's project but is a completely different repo that is being actively maintained. addresses #851
1 parent 6406d90 commit 0e2a879

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"coffeescript": "2.2.4",
3131
"cson": "^3.0.1",
3232
"hjson": "^1.2.0",
33-
"js-yaml": "^3.2.2",
3433
"properties": "~1.2.1",
3534
"request": "^2.88.2",
3635
"semver": "5.3.0",
3736
"toml": "^2.0.6",
3837
"ts-node": "^3.3.0",
3938
"typescript": "^2.4.2",
4039
"underscore": "^1.8.3",
41-
"x2js": "^2.0.1"
40+
"x2js": "^2.0.1",
41+
"yaml": "^2.8.2"
4242
},
4343
"repository": {
4444
"type": "git",

parser.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const JSON5Module = require('json5');
1111
const JSON5 = JSON5Module.default || JSON5Module;
1212

1313
var Yaml = null,
14-
VisionmediaYaml = null,
14+
JSYaml = null,
1515
Coffee = null,
1616
Iced = null,
1717
CSON = null,
@@ -135,34 +135,23 @@ Parser.icedParser = function(filename, content) {
135135
};
136136

137137
Parser.yamlParser = function(filename, content) {
138-
if (!Yaml && !VisionmediaYaml) {
138+
if (!Yaml && !JSYaml) {
139139
// Lazy loading
140140
try {
141-
// Try to load the better js-yaml module
142-
Yaml = require(JS_YAML_DEP);
143-
}
144-
catch (e) {
141+
Yaml = require(YAML_DEP);
142+
} catch (e) {
145143
try {
146-
// If it doesn't exist, load the fallback visionmedia yaml module.
147-
VisionmediaYaml = require(YAML_DEP);
148-
}
149-
catch (e) { }
144+
JSYaml = require(JS_YAML_DEP);
145+
} catch (e) {}
150146
}
151147
}
148+
152149
if (Yaml) {
153-
return Yaml.load(content);
154-
}
155-
else if (VisionmediaYaml) {
156-
// The yaml library doesn't like strings that have newlines but don't
157-
// end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13
158-
content += '\n';
159-
if (typeof VisionmediaYaml.eval === 'function') {
160-
return VisionmediaYaml.eval(Parser.stripYamlComments(content));
161-
}
162-
return VisionmediaYaml.parse(Parser.stripYamlComments(content));
163-
}
164-
else {
165-
console.error('No YAML parser loaded. Suggest adding js-yaml dependency to your package.json file.')
150+
return Yaml.parse(content);
151+
} else if (JSYaml) {
152+
return JSYaml.load(content);
153+
} else {
154+
console.error('No YAML parser loaded. Suggest adding yaml dependency to your package.json file.')
166155
}
167156
};
168157

0 commit comments

Comments
 (0)