Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inquirer-file-selector

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inquirer-file-selector

Inquerer file selector prompt.

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-25.11%
Maintainers
0
Weekly downloads
 
Created
Source

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

OptionTypeRequiredDescription
messagestringThe message to display in the prompt.
basePathstringThe path to the directory where it will be started.
Default: process.cwd()
type'file'︱'directory'︱'file+directory'The type of elements that are valid selection options.
Default: 'file'
pageSizenumberThe maximum number of items to display in the list.
Default: 10
loopbooleanIf true, the list will loop from the last item to the first item and vice versa.
Default: false
filter(file: FileStats) => booleanA function to filter files and directories.
If not provided, all files and directories will be included by default.
showExcludedbooleanIf true, the list will include files and directories that are excluded by the filter function.
Default: false
disabledLabelstringThe label to display when a file is disabled.
Default: (not allowed)
allowCancelbooleanIf true, the prompt will allow the user to cancel the selection.
Default: false
cancelTextstringThe message to display when the user cancels the selection.
Default: Canceled.
emptyTextstringThe message that will be displayed when the directory is empty.
Default: Directory is empty.
themeSee ThemingThe 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 = {
  prefix: {
    idle: string
    done: string
    canceled: string
  }
  icon: {
    linePrefix: (isLast: boolean) => string
  }
  style: {
    disabled: (text: string) => string
    active: (text: string) => string
    cancelText: (text: string) => string
    emptyText: (text: string) => string
    directory: (text: string) => string
    file: (text: string) => string
    currentDir: (text: string) => string
    message: (text: string, status: 'idle' | 'done' | 'canceled') => string
    help: (text: string) => string
    key: (text: string) => string
  }
}

[!NOTE] To see the default theme used by the prompt, look at the fileSelectorTheme constant and the FileSelectorTheme type.

Examples

For examples look in the examples/ directory. You can execute the examples using node.

cd examples/
node <example-name>.js

[!NOTE] Before running the examples, make sure you have installed the dependencies with npm install and compiled the project with npm run build.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am "feat: my new feature"
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

[!NOTE] The commit message should follow the Conventional Commits specification.

© 2024 Brian Fernandez

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

Keywords

FAQs

Package last updated on 30 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc