-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove all sync calls, anything is now async
- Loading branch information
Showing
7 changed files
with
83 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Dependencies from '@/src/types/dependencies' | ||
|
||
/** | ||
* Tells if directory exists | ||
* | ||
* @param directoryPath - The file/folder path | ||
* @param dependencies - Dependencies container | ||
*/ | ||
async function isDirectoryExisting(directoryPath: string, dependencies: Dependencies): Promise<boolean> { | ||
try { | ||
await dependencies.fsAccess(directoryPath) | ||
return Promise.resolve(true) | ||
} catch (error) { | ||
return Promise.resolve(false) | ||
} | ||
} | ||
|
||
export default isDirectoryExisting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
import { ChildProcess, ExecException } from 'child_process' | ||
import { existsSync } from 'fs' | ||
import { normalize, sep } from 'path' | ||
|
||
type ExecFileException = ExecException & NodeJS.ErrnoException | ||
import { access } from 'node:fs/promises' | ||
import { normalize, sep } from 'node:path' | ||
|
||
type Dependencies = { | ||
platform: NodeJS.Platform | ||
release: string | ||
fsExistsSync: typeof existsSync | ||
fsAccess: typeof access | ||
pathNormalize: typeof normalize | ||
pathSep: typeof sep | ||
cpExecFile: ( | ||
file: string, | ||
args: ReadonlyArray<string> | undefined | null, | ||
options: { | ||
windowsHide: true | ||
}, | ||
callback: ( | ||
error: ExecFileException | null, | ||
stdout: string, | ||
stderr: string | ||
) => void | ||
) => ChildProcess | ||
} | ||
) => Promise<{ | ||
stdout: string | ||
stderr: string | ||
}> | ||
} | ||
|
||
export default Dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters