Skip to content

Commit

Permalink
manually revert fix for #1081 (6be9dac)
Browse files Browse the repository at this point in the history
This fix caused #1259.
  • Loading branch information
hegemonic committed Sep 9, 2016
1 parent ed22fa0 commit 8ad5eba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
21 changes: 2 additions & 19 deletions cli.js
Expand Up @@ -314,17 +314,11 @@ function resolvePluginPaths(paths) {
paths.forEach(function(plugin) {
var basename = path.basename(plugin);
var dirname = path.dirname(plugin);
// convoluted way to detect the correct path for the plugins; done this round-about way to cope
// with scenarios where JSDoc is executed in another project's working directory where that
// project has plugins of itself in a similar directory structure (plugins/*)
var pluginPath = path.getResourcePath(dirname, basename + '.js');
var pluginPath = path.getResourcePath(dirname);

if (!pluginPath) {
logger.error('Unable to find the plugin "%s"', plugin);
return;
} else {
// correct the path to the plugin:
pluginPath = path.dirname(pluginPath);
}

pluginPaths.push( path.join(pluginPath, basename) );
Expand Down Expand Up @@ -416,18 +410,7 @@ cli.generateDocs = function() {

env.opts.template = (function() {
var publish = env.opts.template || 'templates/default';
// convoluted way to detect the correct path for the templates; done this round-about way to cope
// with scenarios where JSDoc is executed in another project's working directory where that
// project has templates of itself in a similar directory structure (templates/<name>/)
var templatePath = path.getResourcePath(publish, 'publish.js');

if (!templatePath) {
logger.error('Unable to find the template "%s"', publish);
return publish;
} else {
// correct the path to the template:
templatePath = path.dirname(templatePath);
}
var templatePath = path.getResourcePath(publish);

// if we didn't find the template, keep the user-specified value so the error message is
// useful
Expand Down
16 changes: 1 addition & 15 deletions lib/jsdoc/path.js
Expand Up @@ -111,25 +111,11 @@ exports.getResourcePath = function(filepath, filename) {
return true;
}

function fileExists(_path) {
// see also:
// - http://stackoverflow.com/questions/4482686/check-synchronously-if-file-directory-exists-in-node-js
// - https://nodejs.org/api/fs.html#fs_fs_existssync_path
try {
var stats = fs.lstatSync(_path);

return stats.isFile();
}
catch (e) {
return false;
}
}

// absolute paths are normalized by path.resolve on the first pass
[path.dirname(env.opts.configure || ''), env.pwd, env.dirname].forEach(function(_path) {
if (!result && _path) {
_path = path.resolve(_path, filepath);
if ( pathExists(_path) && (filename ? fileExists(path.join(_path, filename)) : true)) {
if ( pathExists(_path) ) {
result = _path;
}
}
Expand Down

0 comments on commit 8ad5eba

Please sign in to comment.