Skip to content

Commit

Permalink
chore: minor utils imprs
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Nov 22, 2023
1 parent e72fa91 commit 530117c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,16 @@ const findParent = (dir: string, target: string): string | null => {
return dir
}
const parentDir = path.resolve(dir, '..')
if (dir === parentDir) {
return null
}
return findParent(parentDir, target)

return dir === parentDir
? null
: findParent(parentDir, target)
}

const findClosest = (target: string, cwd = __dirname): string | null => {
const found = findParent(cwd, target)

if (!found) {
throw new Error(target)
}
return found ? path.join(found, target) : null
return found
? path.join(found, target)
: null
}

0 comments on commit 530117c

Please sign in to comment.