files-provider
Provides apps with file(s) identified via a regex.
const opener = const HANDLE PROMPT_AND_HANDLE createFilesProvider = const provideFiles = ;async { try await provideFiles catch err console }
Installation
npm install files-provider
API
FilesProvider.fromDirectory
Returns or handles matched files from the given directory.
Parameters
root
String? directory to open files from (defaults to working directory) (optional, defaultprocess.cwd()
)
Returns Array<Object> files if RETURN
is the selected strategy
createFilesProvider
Creates a FilesProvider
Parameters
$0
Object?= {} options$0.regex
RegExp?= null the regex to match the files with$0.single
Number? strategy for handling a single fileHANDLE|RETURN
(optional, defaultPROMPT
)$0.multi
Number? strategy for handling multiple filesHANDLE|PROMPT|RETURN|PROMPT_AND_HANDLE
(optional, defaultPROMPT_AND_HANDLE
)$0.choiceAll
Boolean? iftrue
a choice to select all files is included when multiple files are found (optional, defaulttrue
)$0.handler
function?= null function to call whenHANDLE|PROMPT_AND_HANDLE
strategies are selected$0.promptHeader
String?= defaultPromptHeader header when prompting user to select a file$0.promptFooter
String?= defaultPromptFooter footer when prompting user to select a file
Returns FilesProvider the files provider
License
MIT