Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit a470f4c086de09353ca8f2b024520c11afc68a69 @olalonde committed Oct 22, 2012
Showing with 58 additions and 0 deletions.
  1. +15 −0 .gitignore
  2. +3 −0 README.md
  3. +2 −0 examples/config.yaml
  4. +4 −0 examples/index.js
  5. +11 −0 index.js
  6. +23 −0 package.json
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+node_modules
+npm-debug.log
@@ -0,0 +1,3 @@
+# Reference
+
+http://nodejs.org/api/all.html#all_require_extensions
@@ -0,0 +1,2 @@
+domain: domain.com
+database: my_database
@@ -0,0 +1,4 @@
+require('../');
+var config = require('./config.yaml');
+
+console.log(config);
@@ -0,0 +1,11 @@
+// @see http://nodejs.org/api/all.html#all_require_extensions
+var fs = require('fs')
+ , yaml = require('js-yaml');
+
+require.extensions['.yaml'] =
+require.extensions['.yml'] = function(module, filename) {
+ var content = fs.readFileSync(filename, 'utf8');
+ // Parse the file content and give to module.exports
+ content = yaml.load(content);
+ module.exports = content;
+};
@@ -0,0 +1,23 @@
+{
+ "name": "require-yaml",
+ "version": "0.0.1",
+ "description": "require('require-yaml') lets you load YAML/YML files using require syntax. For example: var config = require('./config.yaml');",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:olalonde/require-yaml.git"
+ },
+ "keywords": [
+ "require",
+ "yaml",
+ "yml"
+ ],
+ "author": "Olivier Lalonde <olalonde@gmail.com>",
+ "license": "BSD",
+ "dependencies": {
+ "js-yaml" : ""
+ }
+}

0 comments on commit a470f4c

Please sign in to comment.