Permalink
Browse files

Merge pull request #24 from enyo/yaml-switch

Yaml switch
  • Loading branch information...
lorenwest committed Jun 1, 2012
2 parents 8814f03 + 8696be2 commit b9464117034deaf335d14317c8b02f89dde70938
Showing 449 changed files with 13,987 additions and 579 deletions.
View
@@ -1,7 +1,8 @@
/*jsl:declare global */
// Dependencies
var Yaml = null, // External libraries are lazy-loaded
- Coffee = null, // only if these file types exist.
+ VisionmediaYaml = null, // only if these file types exist.
+ Coffee = null,
FileSystem = require('fs');
// Static members
@@ -686,12 +687,27 @@ Config.prototype._parseFile = function(fullFilename) {
// Parse the file based on extension
try {
if (extension == 'yaml') {
- // Lazy loading
- Yaml = Yaml || require('yaml');
- // The yaml library doesn't like strings that have newlines but don't
- // end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13
- fileContent += '\n';
- configObject = Yaml.eval(t._stripYamlComments(fileContent));
+ if (!Yaml && !VisionmediaYaml) {
+ // Lazy loading
+ try {
+ // Try to load the better js-yaml module
+ Yaml = require('js-yaml');
+ }
+ catch (e) {
+ // If it doesn't exist, load the fallback visionmedia yaml module.
+ VisionmediaYaml = require('yaml');
+ }
+ }
+
+ if (Yaml) {
+ configObject = Yaml.load(t._stripYamlComments(fileContent));
+ }
+ else if (VisionmediaYaml) {
+ // The yaml library doesn't like strings that have newlines but don't
+ // end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13
+ fileContent += '\n';
+ configObject = VisionmediaYaml.eval(t._stripYamlComments(fileContent));
+ }
}
else if (extension == 'json') {
// Allow comments in JSON files

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit b946411

Please sign in to comment.