Check fs for existsSync. Fixes #21
Updated test to exercise more of the codepaths.
This commit is contained in:
Родитель
ea11e6e6ba
Коммит
f550b17abd
|
@ -11,7 +11,8 @@ var crypto = require('crypto'),
|
|||
path = require('path'),
|
||||
und = require('underscore');
|
||||
|
||||
var opts,
|
||||
var existsSync = fs.existsSync || path.existsSync,
|
||||
opts,
|
||||
_assets,
|
||||
_cache = {};
|
||||
|
||||
|
@ -81,7 +82,7 @@ exports.setup = function (assets, options) {
|
|||
}
|
||||
} else {
|
||||
// Would we ever want to use cachify for non-file resources?
|
||||
if (path.existsSync(path.join(opts.root, true_path))) {
|
||||
if (existsSync(path.join(opts.root, true_path))) {
|
||||
exists = true;
|
||||
_cache[true_path] = {exists: true};
|
||||
} else {
|
||||
|
|
|
@ -55,7 +55,7 @@ exports.setup = nodeunit.testCase({
|
|||
test.equal(express3.version, EXPRESS_3_VER);
|
||||
[express2, express3].forEach(function (express, i) {
|
||||
var app = i === 0 ? express.createServer() : express();
|
||||
app.use(cachify.setup());
|
||||
app.use(cachify.setup([]));
|
||||
app.use(function (req, res, next) {
|
||||
var locals = res.locals();
|
||||
test.ok(!! locals.cachify);
|
||||
|
@ -67,7 +67,7 @@ exports.setup = nodeunit.testCase({
|
|||
var port = server.address().port;
|
||||
console.log('Started web server on port ' + port);
|
||||
var resText = "";
|
||||
var req = http.request({ port: port, path: '/'}, function (res) {
|
||||
var req = http.request({ port: port, path: '/baddecafe1/foo.js'}, function (res) {
|
||||
test.equal(res.statusCode, 200);
|
||||
res.on('data', function (chunk) {
|
||||
resText += chunk;
|
||||
|
|
Загрузка…
Ссылка в новой задаче