Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use glob v5.0.3 to follow symlinks and return realpaths #586

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Expand Up @@ -93,11 +93,9 @@ Node Inspector supports almost all of the debugging features of DevTools, includ

## Known Issues

* Automatic preloading of js files to set breakpoints will not work in
symlinked directories. This is because the [glob](https://github.com/isaacs/node-glob) module doesn't explore
symlinked directories, and it doesn't return "real" paths ([issue](https://github.com/isaacs/node-glob/issues/142).)
The workaround is to allow the debugger to load those modules at runtime and then set the breakpoints.
Not following symlinks does avoid long startup delays when there are symlink cycles.
* If there are symlink cycles the [glob](https://github.com/isaacs/node-glob) module may take
a long time to return results causing long delays at startup. The workaround is to disable
preloading of scripts with `--no-preload`.
* Be careful about viewing the contents of Buffer objects,
each byte is displayed as an individual array element;
for most Buffers this will take too long to render.
Expand Down
12 changes: 9 additions & 3 deletions lib/ScriptFileStorage.js
Expand Up @@ -2,6 +2,7 @@ var fs = require('fs');
var path = require('path');
var async = require('async');
var glob = require('glob');
var debug = require('debug')('node-inspector:ScriptFileStorage');

var MODULE_HEADER = '(function (exports, require, module, __filename, __dirname) { ';
var MODULE_TRAILER = '\n});';
Expand Down Expand Up @@ -149,17 +150,20 @@ $class.listScripts = function(rootFolder, pattern, callback) {
// callback
// );

debug('glob %s on %s', pattern, rootFolder);

glob(
pattern,
{
cwd: rootFolder,
follow: true,
realpath: true,
strict: false
},
function(err, result) {
if (result) {
result = result.map(function(relativeUnixPath) {
var relativePath = relativeUnixPath.split('/').join(path.sep);
return path.join(rootFolder, relativePath);
result = result.map(function(unixPath) {
return unixPath.split('/').join(path.sep);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the paths are returned as absolute, even though you specify rootFolder via options.cwd and not as options.root?

Related: 1c06f8a and isaacs/node-glob@f3105a3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - i had to fix the code above to avoid prepending the rootfolder twice (which breaks inspector). i also had a little exchange with isaacs about the realpath returned paths being absolute now (and the match results not). isaacs/node-glob#184

});
}

Expand All @@ -170,6 +174,7 @@ $class.listScripts = function(rootFolder, pattern, callback) {
result: result
};

debug('glob returned %s files', err || result.length);
callback(err, result);
}.bind(this)
);
Expand Down Expand Up @@ -230,6 +235,7 @@ $class.findAllApplicationScripts = function(startDirectory, mainScriptFile, call
return arr.indexOf(elem) >= ix && !this._scriptManager.isScriptHidden(elem);
}.bind(this));

debug('findAllApplicationScripts returned %s files', files.length);
return callback(null, files);
}.bind(this)
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,7 +25,7 @@
"express": "^4.8.0",
"serve-favicon": "^2.1.1",
"async": "~0.9",
"glob": "^4.3.5",
"glob": "^5.0.5",
"rc": "~0.5.0",
"strong-data-uri": "~0.1.0",
"debug": "^1.0",
Expand Down