File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ module.exports = importPath = (str1, str2) => {
43
43
if ( str1Splited . length === 1 ) {
44
44
finalLocation = "./" ;
45
45
} else {
46
- finalLocation = `${ finalLocation } ../` ;
46
+ for ( let i = 0 ; i < str1Splited . length - 1 ; i ++ ) {
47
+ finalLocation = `${ finalLocation } ../` ;
48
+ }
47
49
}
48
50
49
51
for ( let i = 0 ; i < str2Splited . length - 1 ; i ++ ) {
@@ -55,4 +57,4 @@ module.exports = importPath = (str1, str2) => {
55
57
return finalLocation ;
56
58
} ;
57
59
58
- console . log ( importPath ( "src/route/app/home.js" , "src/route/ utils/helpers.js" ) ) ;
60
+ console . log ( importPath ( "src/route/app/home.js" , "src/utils/helpers.js" ) ) ;
Original file line number Diff line number Diff line change @@ -8,5 +8,9 @@ describe("tets for import path problem", () => {
8
8
"src/route/utils/helpers.js"
9
9
) ;
10
10
expect ( actual ) . toEqual ( expected ) ;
11
+
12
+ expected = "../../utils/helpers.js" ;
13
+ actual = importPath ( "src/route/app/home.js" , "src/utils/helpers.js" ) ;
14
+ expect ( actual ) . toEqual ( expected ) ;
11
15
} ) ;
12
16
} ) ;
You can’t perform that action at this time.
0 commit comments