Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Oct 2, 2023
1 parent 72cebc5 commit a3cfa7d
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ export function pathResourceFork(path: string) {
export function statToPathType(stat: Readonly<Stats>) {
if (stat.isSymbolicLink()) {
return PathType.SYMLINK;
} else if (stat.isDirectory()) {
}
if (stat.isDirectory()) {
return PathType.DIRECTORY;
} else if (stat.isFile()) {
}
if (stat.isFile()) {
return PathType.FILE;
}

Expand Down Expand Up @@ -405,19 +407,7 @@ export async function fsSymlink(
path: string | Readonly<Buffer>,
target: string | Readonly<Buffer>
) {
try {
await symlink(target as string | Buffer, path as string | Buffer);
} catch (err) {
// Workaround for issue in Node v14.5.0 on Windows.
if (
(err as {name: string}).name === 'TypeError' &&
typeof target !== 'string'
) {
await symlink(target.toString(), path as string | Buffer);
} else {
throw err;
}
}
await symlink(target, path);
}

/**
Expand Down Expand Up @@ -482,6 +472,7 @@ export async function fsWalk(
itter: (path: string, stat: Stats) => Promise<boolean | null | void>,
options: Readonly<IFsWalkOptions> = {}
) {
const {ignoreUnreadableDirectories} = options;
const stack = (await fsReaddir(base)).reverse();
while (stack.length) {
const entry = stack.pop() as string;
Expand All @@ -506,12 +497,12 @@ export async function fsWalk(
subs = await fsReaddir(fullPath);
} catch (err) {
if (
err &&
options.ignoreUnreadableDirectories &&
(err as {code: string}).code === 'EACCES'
!(
err &&
ignoreUnreadableDirectories &&
(err as {code: string}).code === 'EACCES'
)
) {
// Skip it.
} else {
throw err;
}
}
Expand Down

0 comments on commit a3cfa7d

Please sign in to comment.