Skip to content

Commit ddea541

Browse files
committed
Use unem instead of const
1 parent 1a7c40a commit ddea541

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

packages/jest-resolve/src/defaultResolver.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ function resolveSync(
142142
}
143143
}
144144

145-
const IS_PATH_FILE = 1;
146-
const IS_PATH_DIRECTORY = 2;
147-
const IS_PATH_OTHER = 3;
148-
const checkedPaths = new Map<string, number>();
145+
enum IPathType {
146+
FILE = 1,
147+
DIRECTORY = 2,
148+
OTHER = 3,
149+
}
150+
const checkedPaths = new Map<string, IPathType>();
149151
function statSyncCached(path: string): number {
150152
const result = checkedPaths.get(path);
151153
if (result !== undefined) {
@@ -163,27 +165,27 @@ function statSyncCached(path: string): number {
163165

164166
if (stat) {
165167
if (stat.isFile() || stat.isFIFO()) {
166-
checkedPaths.set(path, IS_PATH_FILE);
167-
return IS_PATH_FILE;
168+
checkedPaths.set(path, IPathType.FILE);
169+
return IPathType.FILE;
168170
} else if (stat.isDirectory()) {
169-
checkedPaths.set(path, IS_PATH_DIRECTORY);
170-
return IS_PATH_DIRECTORY;
171+
checkedPaths.set(path, IPathType.DIRECTORY);
172+
return IPathType.DIRECTORY;
171173
}
172174
}
173175

174-
checkedPaths.set(path, IS_PATH_OTHER);
175-
return IS_PATH_OTHER;
176+
checkedPaths.set(path, IPathType.OTHER);
177+
return IPathType.OTHER;
176178
}
177179

178180
/*
179181
* helper functions
180182
*/
181183
function isFile(file: Config.Path): boolean {
182-
return statSyncCached(file) === IS_PATH_FILE;
184+
return statSyncCached(file) === IPathType.FILE;
183185
}
184186

185187
function isDirectory(dir: Config.Path): boolean {
186-
return statSyncCached(dir) === IS_PATH_DIRECTORY;
188+
return statSyncCached(dir) === IPathType.DIRECTORY;
187189
}
188190

189191
function isCurrentDirectory(testPath: Config.Path): boolean {

0 commit comments

Comments
 (0)