Commit 3d17cea 1 parent 2461cc9 commit 3d17cea Copy full SHA for 3d17cea
File tree 4 files changed +5
-20
lines changed
4 files changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,3 @@ export function fileExistsAsync(
81
81
callback2 ( undefined , stats ? stats . isFile ( ) : false ) ;
82
82
} ) ;
83
83
}
84
-
85
- export function removeExtension ( path : string ) : string {
86
- return path . substring ( 0 , path . lastIndexOf ( "." ) ) || path ;
87
- }
Original file line number Diff line number Diff line change @@ -148,7 +148,6 @@ function findFirstExistingPath(
148
148
return doneCallback ( err ) ;
149
149
}
150
150
if ( exists ) {
151
- // Not sure why we don't just return the full path? Why strip it?
152
151
return doneCallback ( undefined , TryPath . getStrippedPath ( tryPath ) ) ;
153
152
}
154
153
if ( index === tryPaths . length - 1 ) {
@@ -180,11 +179,7 @@ function findFirstExistingPath(
180
179
return doneCallback ( mainFieldErr ) ;
181
180
}
182
181
if ( mainFieldMappedFile ) {
183
- // Not sure why we don't just return the full path? Why strip it?
184
- return doneCallback (
185
- undefined ,
186
- Filesystem . removeExtension ( mainFieldMappedFile )
187
- ) ;
182
+ return doneCallback ( undefined , mainFieldMappedFile ) ;
188
183
}
189
184
190
185
// No field in package json was a valid option. Continue with the next path.
Original file line number Diff line number Diff line change @@ -118,7 +118,6 @@ function findFirstExistingPath(
118
118
tryPath . type === "index"
119
119
) {
120
120
if ( fileExists ( tryPath . path ) ) {
121
- // Not sure why we don't just return the full path? Why strip it?
122
121
return TryPath . getStrippedPath ( tryPath ) ;
123
122
}
124
123
} else if ( tryPath . type === "package" ) {
@@ -131,8 +130,7 @@ function findFirstExistingPath(
131
130
fileExists
132
131
) ;
133
132
if ( mainFieldMappedFile ) {
134
- // Not sure why we don't just return the full path? Why strip it?
135
- return Filesystem . removeExtension ( mainFieldMappedFile ) ;
133
+ return mainFieldMappedFile ;
136
134
}
137
135
}
138
136
} else {
Original file line number Diff line number Diff line change 1
1
import * as path from "path" ;
2
2
import { MappingEntry } from "./mapping-entry" ;
3
3
import { dirname } from "path" ;
4
- import { removeExtension } from "./filesystem" ;
5
4
6
5
export interface TryPath {
7
6
readonly type : "file" | "extension" | "index" | "package" ;
@@ -60,15 +59,12 @@ export function getPathsToTry(
60
59
return pathsToTry . length === 0 ? undefined : pathsToTry ;
61
60
}
62
61
63
- // Not sure why we don't just return the full found path?
64
62
export function getStrippedPath ( tryPath : TryPath ) : string {
65
63
return tryPath . type === "index"
66
64
? dirname ( tryPath . path )
67
- : tryPath . type === "file"
68
- ? tryPath . path
69
- : tryPath . type === "extension"
70
- ? removeExtension ( tryPath . path )
71
- : tryPath . type === "package"
65
+ : tryPath . type === "file" ||
66
+ tryPath . type === "extension" ||
67
+ tryPath . type === "package"
72
68
? tryPath . path
73
69
: exhaustiveTypeException ( tryPath . type ) ;
74
70
}
You can’t perform that action at this time.
0 commit comments