Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const filePath = await fileSelector({
| 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.<br/> **Default**: `process.cwd()` |
| `basePath` | `string` | | The path to the directory where it will be started.<br/> **Default**: `process.cwd()` |
| `pageSize` | `number` | | The maximum number of items to display in the list.<br/> **Default**: `10` |
| `match` | `(file: Item) => boolean` | | A function to filter the files.<br/> If not provided, all files will be included. |
| `hideNonMatch` | `boolean` | | If true, the list will be filtered to show only files that match the `match` function.<br/> **Default**: `false` |
Expand All @@ -49,6 +49,7 @@ const filePath = await fileSelector({
| `cancelText` | `string` | | The message to display when the user cancels the selection.<br/> **Default**: `Canceled.` |
| `emptyText` | `string` | | The message that will be displayed when the directory is empty.<br/> **Default**: `Directory is empty.` |
| `theme` | [See Theming](#theming) | | The theme to use for the file selector. |
| ~~`path`~~ | ~~`string`~~ | | **Deprecated**: Use `basePath` instead. Will be removed in the next major version. |
| ~~`canceledLabel`~~ | ~~`string`~~ | | **Deprecated**: Use `cancelText` instead. Will be removed in the next major version. |
| ~~`noFilesFound`~~ | ~~`string`~~ | | **Deprecated**: Use `emptyText` instead. Will be removed in the next major version. |

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default createPrompt<string, FileSelectorConfig>((config, done) => {
const prefix = usePrefix({ theme })

const [currentDir, setCurrentDir] = useState(
path.resolve(process.cwd(), config.path || '.')
path.resolve(process.cwd(), config.basePath || config.path || '.')
)

const items = useMemo(() => {
Expand Down
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ export type Item = {

export type FileSelectorConfig = {
message: string
/**
* Alias for `basePath`.
* @deprecated Use `basePath` instead. Will be removed in the next major version.
*/
path?: string
/**
* The path to the directory where it will be started.
* @default process.cwd()
*/
path?: string
basePath?: string
/**
* The maximum number of items to display in the list.
* @default 10
Expand Down