Skip to content

Commit

Permalink
Catnap now loads an index.js file at the root of the project if such
Browse files Browse the repository at this point in the history
file exists.
  • Loading branch information
mikaa123 committed Jan 16, 2015
1 parent 62a332c commit 67446bf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bin/catnap_runner.js
@@ -1,8 +1,11 @@
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
port = process.argv[2] || 3000,
router = express.Router(),
bodyParser = require('body-parser');
cwd = process.cwd();
app = express(),
readdirp,
stream

app
.use(bodyParser.json())
Expand All @@ -20,10 +23,15 @@ app
// Catnap's facade
GLOBAL.catnap = require('../lib/facade')(router);

// Load index.js if the file exists before loading any resource
try {
require(cwd);
} catch(e) { }

// Walk each folders to find *-resource.js files
var readdirp = require('readdirp');
readdirp = require('readdirp');

var stream = readdirp({ root: process.cwd(), fileFilter: '*-resource.js' })
stream = readdirp({ root: cwd, fileFilter: '*-resource.js' })
.on('readable', function () {
require(stream.read().fullPath);
});

0 comments on commit 67446bf

Please sign in to comment.