Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

module: fix --debug-brk on symlinked scripts

* fixes #1519
  • Loading branch information...
commit 27c85727edda169cbe9c04178c6fdee642cb8845 1 parent e806ad3
@indutny indutny authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/module.js
View
16 lib/module.js
@@ -360,6 +360,11 @@ Module.prototype.require = function(path) {
};
+// Resolved path to process.argv[1] will be lazily placed here
+// (needed for setting breakpoint when called with --debug-brk)
+var resolvedArgv;
+
+
// Returns exception if any
Module.prototype._compile = function(content, filename) {
var self = this;
@@ -427,8 +432,15 @@ Module.prototype._compile = function(content, filename) {
var wrapper = Module.wrap(content);
var compiledWrapper = runInThisContext(wrapper, filename, true);
- if (filename === process.argv[1] && global.v8debug) {
- global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0);
+ if (global.v8debug) {
+ if (!resolvedArgv) {
+ resolvedArgv = Module._resolveFilename(process.argv[1], null)[1];
+ }
+
+ // Set breakpoint on module start
+ if (filename === resolvedArgv) {
+ global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0);
+ }
}
var args = [self.exports, require, self, filename, dirname];
return compiledWrapper.apply(self.exports, args);
Please sign in to comment.
Something went wrong with that request. Please try again.