-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
18 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import path from 'path'; | ||
import core from '~/core'; | ||
import { exists as _exists } from '~/utils/file'; | ||
|
||
/** | ||
* Verifies `file` exists and throws if it doesn't. `file` can be either a file or a directory, and be relative to the project's directory. | ||
* @returns A `TScript`, as a function, that won't be executed until called by `kpo` -hence, calling `exists` won't have any effect until the returned function is called. | ||
*/ | ||
export default function exists(file: string) { | ||
return async function exists(): Promise<void> { | ||
if (!path.isAbsolute(file)) { | ||
const paths = await core.paths(); | ||
file = path.join(paths.directory, file); | ||
} | ||
await _exists(file, { fail: true }); | ||
}; | ||
} |
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 +1,2 @@ | ||
export { default as json } from './json'; | ||
export { default as exists } from './exists'; |