1414 * limitations under the License.
1515 */
1616
17- 'use strict' ;
17+ import * as _ from 'lodash' ;
18+ import * as vm from 'vm' ;
19+ import * as path from 'path' ;
20+ import * as semver from 'semver' ;
1821
19- /** @const */ var _ = require ( 'lodash' ) ;
20- /** @const */ var vm = require ( 'vm' ) ;
21- /** @const */ var path = require ( 'path' ) ;
22- /** @const */ var semver = require ( 'semver' ) ;
23-
24- /** @const */ var state = require ( './state.js' ) ;
25- /** @const */ var StatusMessage = require ( '../status-message.js' ) . StatusMessage ;
22+ import * as state from './state' ;
23+ import { StatusMessage } from '../status-message' ;
2624
2725/** @const */ var messages = {
2826 INVALID_BREAKPOINT : 'invalid snapshot - id or location missing' ,
3836 V8_BREAKPOINT_DISABLED : 'Internal error: V8 breakpoint externally disabled' ,
3937 CAPTURE_BREAKPOINT_DATA : 'Error trying to capture snapshot data: ' ,
4038 INVALID_LINE_NUMBER : 'Invalid snapshot position: ' ,
41- COULD_NOT_FIND_OUTPUT_FILE :
39+ COULD_NOT_FIND_OUTPUT_FILE :
4240 'Could not determine the output file associated with the transpiled input file'
4341} ;
4442
@@ -58,7 +56,7 @@ var formatInterval = function(msg, interval) {
5856} ;
5957
6058var singleton ;
61- function create ( logger_ , config_ , jsFiles_ , sourcemapper_ ) {
59+ export function create ( logger_ , config_ , jsFiles_ , sourcemapper_ ) {
6260 if ( singleton && ! config_ . forceNewAgent_ ) {
6361 return singleton ;
6462 }
@@ -314,7 +312,7 @@ function create(logger_, config_, jsFiles_, sourcemapper_) {
314312
315313 // The breakpoint protobuf message presently doesn't have a column property
316314 // but it may have one in the future.
317- var column = mapInfo && mapInfo . column ? mapInfo . column :
315+ var column = mapInfo && mapInfo . column ? mapInfo . column :
318316 ( breakpoint . location . column || 1 ) ;
319317 var line = mapInfo ? mapInfo . line : breakpoint . location . line ;
320318
@@ -566,7 +564,8 @@ function pathToRegExp(scriptPath) {
566564 return new RegExp ( scriptPath + '$' ) ;
567565}
568566
569- function findScripts ( scriptPath , config , fileStats ) {
567+ // Exposed for unit testing.
568+ export function findScripts ( scriptPath , config , fileStats ) {
570569 // Use repository relative mapping if present.
571570 if ( config . appPathRelativeToRepository ) {
572571 var candidate = scriptPath . replace ( config . appPathRelativeToRepository ,
@@ -589,7 +588,7 @@ function findScripts(scriptPath, config, fileStats) {
589588 * Given an list of available files and a script path to match, this function
590589 * tries to resolve the script to a (hopefully unique) match in the file list
591590 * disregarding the full path to the script. This can be useful because repo
592- * file paths (that the UI has) may not necessarily be suffixes of the absolute
591+ * file paths (that the UI has) may not necessarily be suffixes of the absolute
593592 * paths of the deployed files. This happens when the user deploys a
594593 * subdirectory of the repo.
595594 *
@@ -610,7 +609,8 @@ function findScripts(scriptPath, config, fileStats) {
610609 * available.
611610 * @return {array<string> } list of files that match.
612611 */
613- function findScriptsFuzzy ( scriptPath , fileList ) {
612+ // Exposed for unit testing.
613+ export function findScriptsFuzzy ( scriptPath , fileList ) {
614614 var matches = fileList ;
615615 var components = scriptPath . split ( path . sep ) ;
616616 for ( var i = components . length - 1 ; i >= 0 ; i -- ) {
@@ -622,10 +622,3 @@ function findScriptsFuzzy(scriptPath, fileList) {
622622 }
623623 return matches ;
624624}
625-
626- module . exports = {
627- create : create ,
628- // Exposed for unit testing.
629- findScripts : findScripts ,
630- findScriptsFuzzy : findScriptsFuzzy
631- } ;
0 commit comments