Skip to content

Commit

Permalink
Fix glob.sync throwing when it can't access a directory apidoc#43
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed Jan 13, 2017
1 parent c1c3cdf commit 22bf305
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/plugin_loader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var _ = require('lodash');
var fs = require('fs');
var path = require('path');
var util = require('util');
var glob = require('glob');
Expand Down Expand Up @@ -44,19 +43,15 @@ module.exports = PluginLoader;
PluginLoader.prototype.detectPugins = function(dir) {
var self = this;

// Every dir start with "apidoc-plugin-", because for the tests of apidoc-plugin-test.
var plugins;
try {
if (dir === '/') {
fs.accessSync(dir + '.');
} else {
fs.accessSync(dir + '/.');
}
plugins = glob.sync(dir + '/apidoc-plugin-*');
} catch (e) {
app.log.warn(e);
return;
}

// Every dir start with "apidoc-plugin-", because for the tests of apidoc-plugin-test.
var plugins = glob.sync(dir + '/apidoc-plugin-*');
if (plugins.length === 0) {
dir = path.join(dir, '..');
if (dir === '/' || dir.substr(1) === ':\\') {
Expand Down

0 comments on commit 22bf305

Please sign in to comment.