Skip to content

Instantly share code, notes, and snippets.

@MarcoNicolodi
Last active January 27, 2019 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcoNicolodi/4e4941deccfa28a5ac8863a9e3ed8769 to your computer and use it in GitHub Desktop.
Save MarcoNicolodi/4e4941deccfa28a5ac8863a9e3ed8769 to your computer and use it in GitHub Desktop.
function useChooseFile(finder) {
return function({ directory, message, matching }) {
const candidateFiles = await finder({ directory, matching })
const promptOptions = {
name: 'chosenFile',
message,
choices: ['all', prompt.separator(), ...candidateFiles]
}
const { chosenFile } = await prompt.ask(promptOptions)
return chosenFile
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment