Skip to content

Function: pathExists() ​

pathExists(path): Promise<boolean>

Tell whether a file or a directory exists at a path. A path which cannot be checked (a parent directory without permission) is reported as missing; a symbolic link is followed, so a broken link is missing too.

Parameters ​

path ​

PathLike

The path: a string (relative to the current working directory), a Buffer or a file: URL.

Returns ​

Promise<boolean>

A promise of true when the path exists, false otherwise; it never rejects.

Example ​

typescript
import {pathExists} from 'lakutata/utils'

if (!(await pathExists('./config.json'))) console.log('No configuration file, using the defaults')

Released under the MIT License.