inquirer-file-selector
An file selector prompt implementation for Inquirer.js.

Installation
npm install inquirer-file-selector
Usage
import fileSelector from 'inquirer-file-selector'
const filePath = await fileSelector({
message: 'Select a file:',
...
})
Options
message | string | ✔ | The message to display in the prompt. |
path | string | | The path to the directory where it will be started. Default: process.cwd() |
pageSize | number | | The maximum number of items to display in the list. Default: 10 |
extensions | string[] | | The extensions to filter the files. Default: [] |
disabledLabel | string | | The label to display when a file is disabled. Default: (not allowed) |
noFilesFound | string | | The message to display when no files are found. Default: No files found |
theme | See Theming | | The theme to use for the file selector. |
Theming
You can theme a prompt by passing a theme
object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.
type FileSelectorTheme = {
icon: {
linePrefix: (isLast: boolean) => string
}
style: {
disabled: (text: string) => string
active: (text: string) => string
noFilesFound: (text: string) => string
directory: (text: string) => string
file: (text: string) => string
currentDir: (text: string) => string
help: (text: string) => string
key: (text: string) => string
}
}
Copyright & License
© 2024 Brian Fernandez
This project is licensed under the MIT license. See the file LICENSE for details.