nearest-file-path
Find a relative path in a directory, travelling up the ancestral chain until found.
Example
/* File system: / x /a y /b */ // Find a fileconsole // '/x'// Find a relative pathconsole // '/a/y'// Find a directoryconsole // '/a/b'// Find the unfindableconsole // Error // or the synchronous wayconsole // '/x'
nearest(subpath[, basepath])
subpath is a relative path to a file or directory.
basepath is an optional path to a nested directory from which to search upwards until the subpath is found. Defaults to the current working directory.
Asynchronous with promises for that async
/await
goodness. Resolves with the absolute path as a string. Otherwise throws an error.
nearestSync(subpath[, basepath])
Identical arguments as #nearestsubpath-basepath.
Synchronous for specific use-cases where performance is not crucial. Remember to use asynchronous code where possible.