@@ -287,8 +287,8 @@ function create(logger_, config_, jsFiles_, sourcemapper_) {
287287 // we are going to assume that repository root === the starting working
288288 // directory.
289289 var matchingScript ;
290- var scripts = findScripts ( mapInfo ? mapInfo . file :
291- path . normalize ( breakpoint . location . path ) ) ;
290+ var scripts = findScripts ( mapInfo ? mapInfo . file :
291+ path . normalize ( breakpoint . location . path ) , config , fileStats ) ;
292292 if ( scripts . length === 0 ) {
293293 return setErrorStatusAndCallback ( cb , breakpoint ,
294294 StatusMessage . BREAKPOINT_SOURCE_LOCATION ,
@@ -406,25 +406,6 @@ function create(logger_, config_, jsFiles_, sourcemapper_) {
406406 // return v8bp;
407407 // }
408408
409- function findScripts ( scriptPath ) {
410- // Use repository relative mapping if present.
411- if ( config . appPathRelativeToRepository ) {
412- var candidate = scriptPath . replace ( config . appPathRelativeToRepository ,
413- config . workingDirectory ) ;
414- // There should be no ambiguity resolution if project root is provided.
415- return fileStats [ candidate ] ? [ candidate ] : [ ] ;
416- }
417- var regexp = pathToRegExp ( scriptPath ) ;
418- // Next try to match path.
419- var matches = Object . keys ( fileStats ) . filter ( regexp . test . bind ( regexp ) ) ;
420- if ( matches . length === 1 ) {
421- return matches ;
422- }
423-
424- // Finally look for files with the same name regardless of path.
425- return findScriptsFuzzy ( scriptPath , Object . keys ( fileStats ) ) ;
426- }
427-
428409 function onBreakpointHit ( breakpoint , callback , execState ) {
429410 var v8bp = breakpoints [ breakpoint . id ] . v8Breakpoint ;
430411
@@ -584,6 +565,25 @@ function pathToRegExp(scriptPath) {
584565 return new RegExp ( scriptPath + '$' ) ;
585566}
586567
568+ function findScripts ( scriptPath , config , fileStats ) {
569+ // Use repository relative mapping if present.
570+ if ( config . appPathRelativeToRepository ) {
571+ var candidate = scriptPath . replace ( config . appPathRelativeToRepository ,
572+ config . workingDirectory ) ;
573+ // There should be no ambiguity resolution if project root is provided.
574+ return fileStats [ candidate ] ? [ candidate ] : [ ] ;
575+ }
576+ var regexp = pathToRegExp ( scriptPath ) ;
577+ // Next try to match path.
578+ var matches = Object . keys ( fileStats ) . filter ( regexp . test . bind ( regexp ) ) ;
579+ if ( matches . length === 1 ) {
580+ return matches ;
581+ }
582+
583+ // Finally look for files with the same name regardless of path.
584+ return findScriptsFuzzy ( scriptPath , Object . keys ( fileStats ) ) ;
585+ }
586+
587587/**
588588 * Given an list of available files and a script path to match, this function
589589 * tries to resolve the script to a (hopefully unique) match in the file list
@@ -625,5 +625,6 @@ function findScriptsFuzzy(scriptPath, fileList) {
625625module . exports = {
626626 create : create ,
627627 // Exposed for unit testing.
628+ findScripts : findScripts ,
628629 findScriptsFuzzy : findScriptsFuzzy
629630} ;
0 commit comments