Skip to content

Commit

Permalink
remove check for file existence to allow require to choke on broken s…
Browse files Browse the repository at this point in the history
…ymlinks later on
  • Loading branch information
Ville Saukkonen committed Nov 15, 2016
1 parent 20f56ca commit ab3d1c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var readdirSync = require('fs').readdirSync;
var statSync = require('fs').statSync;
var watchFile = require('fs').watchFile;
var lstatSync = require('fs').lstatSync;
var existsSync = require('fs').existsSync;
var toISOString = require('./to-iso-string');

/**
Expand Down Expand Up @@ -256,7 +255,7 @@ exports.files = function (dir, ext, ret) {
path = join(dir, path);
if (lstatSync(path).isDirectory()) {
exports.files(path, ext, ret);
} else if (path.match(re) && existsSync(path)) {
} else if (path.match(re)) {
ret.push(path);
}
});
Expand Down
8 changes: 4 additions & 4 deletions test/acceptance/file-utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var mkdirp = require('mkdirp');
var rimraf = require('rimraf');

describe('file utils', function () {
var tmpDir = path.join(os.tmpDir(), 'mocha-file-test-folder');
var tmpDir = path.join(os.tmpDir(), 'mocha-file-lookup');
var existsSync = fs.existsSync;
var tmpFile = path.join.bind(path, tmpDir);
var symlinkSupported = false;
Expand Down Expand Up @@ -37,7 +37,7 @@ describe('file utils', function () {
});

describe('.lookupFiles', function () {
(symlinkSupported ? it : it.skip)('lookupFiles should not choke on broken symlinks', function () {
(symlinkSupported ? it : it.skip)('should not return broken symlink file path', function () {
expect(utils.lookupFiles(tmpDir, ['js'], false))
.to
.contain(tmpFile('mocha-utils-link.js'))
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('file utils', function () {
});

describe('.files', function () {
(symlinkSupported ? it : it.skip)('should not choke on broken symlinks', function () {
(symlinkSupported ? it : it.skip)('should return broken symlink file path', function () {
expect(utils.files(tmpDir, ['js']))
.to.contain(tmpFile('mocha-utils-link.js'))
.and.contain(tmpFile('mocha-utils.js'))
Expand All @@ -96,7 +96,7 @@ describe('file utils', function () {
.to.be(false);

expect(utils.files(tmpDir, ['js']))
.to.eql([]);
.to.eql([tmpFile('mocha-utils-link.js')]);
});
});

Expand Down

0 comments on commit ab3d1c0

Please sign in to comment.