We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { glob } from 'glob' import fs from 'node:fs' const cwd = { message: `Current working directory (ex. ~/project, ../project, ./project):`, type: `autocomplete`, limit: 10, choices: [ /* force prompts to render 10 lines */ { title: `Current working directory`, value: process.cwd() }, { title: `Parent directory`, value: `../` }, { title: `Grand directory`, value: `../../` }, { title: `Home directory`, value: `~` }, { title: `Root directory`, value: `/` }, { title: `reserved-1`, value: `./` }, { title: `reserved-2`, value: `./` }, { title: `reserved-3`, value: `./` }, { title: `reserved-4`, value: `./` }, { title: `reserved-5`, value: `./` }, ], suggest: async (input, _choices) => { const cwd = process.cwd() const start = (input.length === 0 ? cwd : input).replace('~', process.env.HOME) const files = await glob(`${start}*`, { cwd, maxDepth: 1 }) const value = files?.[0] ?? start const suggestions = files ?? [value] return suggestions .filter((f) => f !== '.' && f !== '..') .filter((f) => { try { return fs.lstatSync(f).isDirectory() } catch (error) { return false } }) .map((f) => ({ title: f })) .slice(0, 10) }, }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: