Last active
January 27, 2019 14:18
-
-
Save MarcoNicolodi/9674d2ce9c2e13cea56e3bb2731ca1e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chooseFile = async ({ directory, message, matching }) => { | |
let candidateFiles | |
if (matching) { | |
candidateFiles = await filesystem.find(directory, { matching }) | |
} else { | |
candidateFiles = await filesystem.list(directory) | |
} | |
const promptConfig = { | |
name: 'chosenFile', | |
message, | |
choices: ['all', prompt.separator(), ...candidateFiles] | |
} | |
const { chosenFile } = await prompt.ask(promptConfig) | |
return chosenFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment