Skip to content
Browse files

use isFIFO() instead to more narrowly target <() usage

  • Loading branch information...
1 parent c396065 commit 790cdf5ab7c92bb146e8ace05ba0b26c5f51ffb3 @substack committed Mar 29, 2013
Showing with 4 additions and 3 deletions.
  1. +1 −1 lib/async.js
  2. +3 −2 lib/sync.js
View
2 lib/async.js
@@ -15,7 +15,7 @@ module.exports = function resolve (x, opts, cb) {
fs.stat(file, function (err, stat) {
if (err && err.code === 'ENOENT') cb(null, false)
else if (err) cb(err)
- else cb(null, !stat.isDirectory())
+ else cb(null, stat.isFile() || stat.isFIFO())
});
};
var readFile = opts.readFile || fs.readFile;
View
5 lib/sync.js
@@ -1,14 +1,15 @@
var core = require('./core');
var fs = require('fs');
var path = require('path');
-var existsSync = fs.existsSync || path.existsSync;
module.exports = function (x, opts) {
if (core[x]) return x;
if (!opts) opts = {};
var isFile = opts.isFile || function (file) {
- return existsSync(file) && !fs.statSync(file).isDirectory()
+ try { var stat = fs.statSync(file) }
+ catch (err) { if (err && err.code === 'ENOENT') return false }
+ return stat.isFile() || stat.isFIFO();
};
var readFileSync = opts.readFileSync || fs.readFileSync;

0 comments on commit 790cdf5

Please sign in to comment.
Something went wrong with that request. Please try again.