Skip to content

Commit

Permalink
Merge pull request #24 from enyo/yaml-switch
Browse files Browse the repository at this point in the history
Yaml switch
  • Loading branch information
lorenwest committed Jun 1, 2012
2 parents 8814f03 + 8696be2 commit b946411
Show file tree
Hide file tree
Showing 449 changed files with 13,987 additions and 579 deletions.
30 changes: 23 additions & 7 deletions lib/config.js
@@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions node_modules/js-yaml/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/js-yaml/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions node_modules/js-yaml/HISTORY.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/js-yaml/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions node_modules/js-yaml/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b946411

Please sign in to comment.