Skip to content

Instantly share code, notes, and snippets.

@almost
Created May 11, 2012 11:19

Revisions

  1. almost revised this gist May 11, 2012. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,11 @@ var fs = require('fs'), path = require('path');

    // Load all exported objects into a single module.
    fs.readdirSync(__dirname).forEach(function (filename) {
    var fullpath = path.join(__dirname, filename), resource;
    var fullpath = path.join(__dirname, filename), resource,
    module;

    if (fullpath !== __filename && 'js' === fullpath.split('.').pop() && '.' !== fullpath[0]) {
    resource = require(fullpath);
    exports[resource.name] = resource;
    module = require(fullpath);
    exports[filename.split('.')[0]] = module;
    }
    });
    });
  2. almost revised this gist May 11, 2012. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    var fs = require('fs'), path = require('path');

    // Load all exported objects into a single module.
    // Allows require('resources').Meeting instead of require('resources/meeting')
    fs.readdirSync(__dirname).forEach(function (filename) {
    var fullpath = path.join(__dirname, filename), resource;
    if (fullpath !== __filename && 'js' === fullpath.split('.').pop() && '.' !== fullpath[0]) {
  3. almost renamed this gist May 11, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. almost created this gist May 11, 2012.
    11 changes: 11 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    var fs = require('fs'), path = require('path');

    // Load all exported objects into a single module.
    // Allows require('resources').Meeting instead of require('resources/meeting')
    fs.readdirSync(__dirname).forEach(function (filename) {
    var fullpath = path.join(__dirname, filename), resource;
    if (fullpath !== __filename && 'js' === fullpath.split('.').pop() && '.' !== fullpath[0]) {
    resource = require(fullpath);
    exports[resource.name] = resource;
    }
    });