Skip to content

Commit

Permalink
Use unem instead of const
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha committed May 1, 2019
1 parent 1a7c40a commit ddea541
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/jest-resolve/src/defaultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ function resolveSync(
}
}

const IS_PATH_FILE = 1;
const IS_PATH_DIRECTORY = 2;
const IS_PATH_OTHER = 3;
const checkedPaths = new Map<string, number>();
enum IPathType {
FILE = 1,
DIRECTORY = 2,
OTHER = 3,
}
const checkedPaths = new Map<string, IPathType>();
function statSyncCached(path: string): number {
const result = checkedPaths.get(path);
if (result !== undefined) {
Expand All @@ -163,27 +165,27 @@ function statSyncCached(path: string): number {

if (stat) {
if (stat.isFile() || stat.isFIFO()) {
checkedPaths.set(path, IS_PATH_FILE);
return IS_PATH_FILE;
checkedPaths.set(path, IPathType.FILE);
return IPathType.FILE;
} else if (stat.isDirectory()) {
checkedPaths.set(path, IS_PATH_DIRECTORY);
return IS_PATH_DIRECTORY;
checkedPaths.set(path, IPathType.DIRECTORY);
return IPathType.DIRECTORY;
}
}

checkedPaths.set(path, IS_PATH_OTHER);
return IS_PATH_OTHER;
checkedPaths.set(path, IPathType.OTHER);
return IPathType.OTHER;
}

/*
* helper functions
*/
function isFile(file: Config.Path): boolean {
return statSyncCached(file) === IS_PATH_FILE;
return statSyncCached(file) === IPathType.FILE;
}

function isDirectory(dir: Config.Path): boolean {
return statSyncCached(dir) === IS_PATH_DIRECTORY;
return statSyncCached(dir) === IPathType.DIRECTORY;
}

function isCurrentDirectory(testPath: Config.Path): boolean {
Expand Down

0 comments on commit ddea541

Please sign in to comment.