11import { join } from 'path' ;
2- import { isWindows , fixPathForWindows } from './system' ;
2+ import { isWindows } from './system' ;
33
44/*
55 import paths won't match the context of the test runner
@@ -12,9 +12,6 @@ const importPathRegex =
1212const relativePathRegex = / ^ B A S E / ;
1313
1414export default function fixImportPaths ( { dir, content} ) : string {
15- // collect import lines
16- let entries = new Set ( [ ] ) ;
17-
1815 return content . split ( '\n' ) . map ( line => {
1916 // line has an import or require ?
2017 const isMatch = line . match ( importPathRegex ) ;
@@ -27,20 +24,19 @@ export default function fixImportPaths({dir, content}): string {
2724
2825 // is a relative path
2926 if ( importPath . match ( relativePathRegex ) ) {
30- let newPath = join ( dir , importPath . replace ( 'BASE' , '' ) ) ;
27+ let newPath ;
3128
32- // fix buggy Windows paths
3329 if ( isWindows ) {
34- newPath = fixPathForWindows ( newPath ) ;
30+ // fix buggy Windows paths
31+ // note: necessary to split and join before newPath is set to
32+ // a variable or backslashes are interpreted as escaped characters
33+ newPath = join ( dir , importPath . replace ( 'BASE' , '' ) )
34+ . split ( '\\' ) . join ( '\\\\' ) ;
35+ } else {
36+ newPath = join ( dir , importPath . replace ( 'BASE' , '' ) ) ;
3537 }
3638
37- const newLine = line . replace ( importPath , newPath ) ;
38- // add to map of entry files
39- if ( ! entries . has ( newLine ) ) {
40- entries . add ( newLine ) ;
41- return newLine ;
42- }
43- return '' ;
39+ return line . replace ( importPath , newPath ) ;
4440 }
4541 // no match, return line
4642 return line ;
0 commit comments