Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit a470f4c086de09353ca8f2b024520c11afc68a69 0 parents
@olalonde authored
15 .gitignore
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+node_modules
+npm-debug.log
3  README.md
@@ -0,0 +1,3 @@
+# Reference
+
+http://nodejs.org/api/all.html#all_require_extensions
2  examples/config.yaml
@@ -0,0 +1,2 @@
+domain: domain.com
+database: my_database
4 examples/index.js
@@ -0,0 +1,4 @@
+require('../');
+var config = require('./config.yaml');
+
+console.log(config);
11 index.js
@@ -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;
+};
23 package.json
@@ -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" : ""
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.