Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fs.exists

  • Loading branch information...
commit 014de384195d505f50b3722e2c1396415209daf7 1 parent e5c770c
@partheseas authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 Library/trailer.js
View
15 Library/trailer.js
@@ -15,6 +15,11 @@ url = require( "url" ),
markdown = require( "markdown" ),
zlib = require( "zlib" );
+// fs.exists compatibility
+if ( !fs.exists ) {
+ fs.exists = path.exists
+}
+
// This isn't one of our event emitters,
// because then it would emit to itself in an infinite loop.
global.trailer = trailer = module.exports = new events.EventEmitter()
@@ -196,13 +201,13 @@ http.ServerResponse.prototype.error = function () {
if ( Function.is( i.conf.errors[ o.status ] ) ) {
i.conf.errors[ o.status ]( i, o )
} else {
- path.exists( i.conf.errors[ o.status ], function ( exists ) {
+ fs.exists( i.conf.errors[ o.status ], function ( exists ) {
if ( exists ) {
fs.readFile( i.conf.errors[ o.status ], function ( error, content ) {
o.finish( content )
})
} else {
- path.exists( path.join( i.conf.root, i.conf.errors[ o.status ] ), function ( exists ) {
+ fs.exists( path.join( i.conf.root, i.conf.errors[ o.status ] ), function ( exists ) {
if ( exists ) {
fs.readFile( path.join( i.conf.root, i.conf.errors[ o.status ] ), function ( error, content ) {
o.finish( content )
@@ -260,7 +265,7 @@ http.ServerResponse.prototype.finish = function () {
rid = 0
-server.on( 'request', function ( i, o ) {
+server.on( "request", function ( i, o ) {
i.received = new Date(),
i.rid = rid++,
i.host = ( /(www[0-9]*\.)*([a-z0-9\-\.]+|\[[abcdef0-9\:]+\])(\:[0-9]+)?/i.exec( i.headers.host ) || [] )[2],
@@ -322,7 +327,7 @@ trailer.GET = trailer.POST = trailer.HEAD = function ( i, o ) {
} )
if ( !other ) {
- path.exists( i.path, function ( exists ) {
+ fs.exists( i.path, function ( exists ) {
if ( exists ) {
o.status = 200
fs.stat( i.path, function ( error, stats ) {
@@ -367,7 +372,7 @@ trailer.GET = trailer.POST = trailer.HEAD = function ( i, o ) {
file = indexes[ index ]
if ( index < indexes.length ) {
if ( i.depth <= i.conf.indexes[ file ] ) {
- path.exists( path.resolve( i.path, file ), function ( exists ) {
+ fs.exists( path.resolve( i.path, file ), function ( exists ) {
if ( exists ) {
i.path = path.resolve( i.path, file )
i.handler( i, o )
Please sign in to comment.
Something went wrong with that request. Please try again.