JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9228
  • Score
    100M100P100Q141523F
  • License MIT

Inquerer file selector prompt.

Package Exports

  • inquirer-file-selector
  • inquirer-file-selector/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inquirer-file-selector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

inquirer-file-selector

An file selector prompt implementation for Inquirer.js.

license node-current version unpacked-size downloads

preview

Installation

npm install inquirer-file-selector

Usage

import fileSelector from 'inquirer-file-selector'

const filePath = await fileSelector({
  message: 'Select a file:',
  ...
})

Options

Option Type Required Description
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
match (file: Item) => boolean A function to filter the files.
If not provided, all files will be included.
hideNonMatch boolean If true, the list will be filtered to only show files that match the extensions.
Default: false
disabledLabel string The label to display when a file is disabled.
Default: (not allowed)
allowCancel boolean If true, the prompt will allow the user to cancel the selection.
Default: false
canceledLabel string The label to display when the prompt is canceled.
Default: Canceled
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.
extensions string[] The extensions to filter the files.
(Deprecated in favor of match option)

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: {
    /**
     * The prefix to use for the line.
     * @default isLast => isLast ? └── : ├──
     */
    linePrefix: (isLast: boolean) => string
  }
  style: {
    /**
     * The style to use for the disabled items.
     * @default chalk.dim
     */
    disabled: (text: string) => string
    /**
     * The style to use for the active item.
     * @default chalk.cyan
     */
    active: (text: string) => string
    /**
     * The style to use for the no files found message.
     * @default chalk.red
     */
    noFilesFound: (text: string) => string
    /**
     * The style to use for items of type directory.
     * @default chalk.yellow
     */
    directory: (text: string) => string
    /**
     * The style to use for items of type file.
     * @default chalk.white
     */
    file: (text: string) => string
    /**
     * The style to use for the current directory header.
     * @default chalk.magenta
     */
    currentDir: (text: string) => string
    /**
     * The style to use for the key bindings help.
     * @default chalk.white
     */
    help: (text: string) => string
    /**
     * The style to use for the keys in the key bindings help.
     * @default chalk.cyan
     */
    key: (text: string) => string
  }
}

© 2024 Brian Fernandez

This project is licensed under the MIT license. See the file LICENSE for details.