functions body
* `setBreakpoint('script.js', 1)`, `sb(...)` - Set breakpoint on first line of
script.js
-* `clearBreakpoint`, `cb(...)` - Clear breakpoint
+* `clearBreakpoint('script.js', 1)`, `cb(...)` - Clear breakpoint in script.js
+on line 1
It is also possible to set a breakpoint in a file (module) that
isn't loaded yet:
// setBreakpoint('scriptname')
if (script != +script && !this.client.scripts[script]) {
var scripts = this.client.scripts;
- var keys = Object.keys(scripts);
- for (var v = 0; v < keys.length; v++) {
- var id = keys[v];
+ for (var id in scripts) {
if (scripts[id] &&
scripts[id].name &&
scripts[id].name.indexOf(script) !== -1) {
var ambiguous,
breakpoint,
+ scriptId,
index;
this.client.breakpoints.some(function(bp, i) {
if (!util.isUndefined(index)) {
ambiguous = true;
}
+ scriptId = script;
if (bp.line === line) {
index = i;
breakpoint = bp.id;
}
});
+ if (!scriptId && !this.client.scripts[script]) {
+ var scripts = this.client.scripts;
+ for (var id in scripts) {
+ if (scripts[id] &&
+ scripts[id].name &&
+ scripts[id].name.indexOf(script) !== -1) {
+ if (scriptId) {
+ ambiguous = true;
+ }
+ scriptId = id;
+ }
+ }
+ }
+
if (ambiguous) return this.error('Script name is ambiguous');
+ if (util.isUndefined(scriptId)) {
+ return this.error('Script ' + script + ' not found');
+ }
+
if (util.isUndefined(breakpoint)) {
- return this.error('Script : ' + script + ' not found');
+ return this.error('Breakpoint not found on line ' + line);
}
var self = this,