Skip to content

Guide on Using basePath and match #21

Closed Answered by amsyarzero
amsyarzero asked this question in Q&A
Discussion options

You must be logged in to vote

nvm, I immediately found the answers 😅

Solutions

basePath

Use NodeJS's os and path packages. The former provides system utility methods, while the latter is all about PATHs. For example, if I want inquirer-file-selector to start on Documents no matter what Windows setup it's running on, it's:

const documentPath = path.join(os.homedir(), "Documents");

match

After looking at examples/recursive.js, there's an example that shows how to implement the param, Line 17.

match: (file) => file.name.endsWith('.json'),

So, to filter by file extension, simply use the code above and change the extension in the brackets.

Hopefully this helps anyone else with using this awesome prompt!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amsyarzero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant