Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Check `err.code` instead of `err.errno` for 0.5.x compat.

  • Loading branch information...
commit e58f0d3a0cc90e3e3197e9824c5570ebcb665599 1 parent 1a59c6b
@TooTallNate TooTallNate authored
Showing with 3 additions and 5 deletions.
  1. +1 −3 indexer.js
  2. +1 −0  share.js
  3. +1 −2  static.js
View
4 indexer.js
@@ -3,8 +3,6 @@ var Fs = require('fs'),
Url = require('url'),
getMime = require('simple-mime')("application/octet-stream");
-var ENOENT = process.ENOENT || require('constants').ENOENT;
-
module.exports = function setup(mount, root, showHidden) {
return function handle(req, res, next) {
@@ -17,7 +15,7 @@ module.exports = function setup(mount, root, showHidden) {
if (path[path.length - 1] === '/') { path = path.substr(0, path.length - 1); }
Fs.stat(path, function (err, stat) {
if (err) {
- if (err.errno === ENOENT) { return next(); }
+ if (err.code === 'ENOENT') { return next(); }
return next(err);
}
if (!stat.isDirectory()) {
View
1  share.js
@@ -16,6 +16,7 @@ function listen() {
Http.createServer(handler).listen(PORT);
console.log("Serving %s at http://localhost:%s/", path, PORT);
} catch (err) {
+ // this is probably broken in node 0.5.x. Should check err.code instead.
if (err.errno !== 98) { throw err; }
PORT++;
listen();
View
3  static.js
@@ -4,7 +4,6 @@ var Path = require('path'),
getMime = require('simple-mime')("application/octet-stream");
// Compat stuff to make this work on the v0.2.x and v0.3.x branches of node
-var ENOENT = process.ENOENT || require('constants').ENOENT;
var StreamProto = require('net').Stream.prototype.__proto__;
if (!StreamProto.hasOwnProperty('pipe')) {
var sys = require('sys');
@@ -38,7 +37,7 @@ module.exports = function setup(mount, root, index) {
}
function onStat(err, stat) {
if (err) {
- if (err.errno === ENOENT) { return next(); }
+ if (err.code === 'ENOENT') { return next(); }
return next(err);
}
if (index && stat.isDirectory()) {
Please sign in to comment.
Something went wrong with that request. Please try again.