extract-path1.0.0 • Public • Published
Extract a valid fs path from a string.
extract-path is a node library that will attempt to find a possible valid file system path for a given input, validate its existance within the file system and return the matching value upon confirmation.
Table of Contents
The main use case for the lib is to be able to take valid path values out of verbose outputs such as those generated by a
git status command:
modified: src/Router.jsresolves to
?? src/utils/__tests__/file.test.jsresolves to
This library was primarily put together for usage in iPipeTo which allows for its users to easily extract a path out of a random input value. Some extra effort was made to ensure extract-path works well as a separated lib in the hope that it can be useful for different use cases out there. Feel free to refer to iPipeTo source code as a implementation example if ever needed.
npm install extract-path
// example.jsconst extractPath = ;;
The API only exposes a single function, that receives a
string and returns a
Promise which resolves with a single, valid
string value or
undefined if there was no possible match.
stringvalue to be parsed in order to extract a valid fs path
- opts [optional]
objectcontaining the following:
booleanwether the module should validate the file exists, defaults to
booleanuses a fallback system that matches the entire input if a path couldn't be infered from the input, defaults to
extract-path is heavily inspired by the work done in PathPicker parsing algorithm and regular expressions.
iPipeTo - Interactive Pipe To: The missing cli interactive workflow
Please do! This is an open source project. If you have a bug or want to discuss something, open an issue.