* Extracts the list of files from argv.files. Throws an error if no matching * files were found. * * @return {Array }
()
| 76 | * @return {Array<string>} |
| 77 | */ |
| 78 | function getFilesFromArgv() { |
| 79 | if (!argv.files) { |
| 80 | return []; |
| 81 | } |
| 82 | const toPosix = (str) => str.replace(/\\\\?/g, '/'); |
| 83 | const globs = Array.isArray(argv.files) ? argv.files : argv.files.split(','); |
| 84 | const allFiles = []; |
| 85 | for (const glob of globs) { |
| 86 | const files = fastGlob.sync(toPosix(glob.trim())); |
| 87 | if (files.length == 0) { |
| 88 | log(red('ERROR:'), 'Argument', cyan(glob), 'matched zero files.'); |
| 89 | throw new Error('Argument matched zero files.'); |
| 90 | } |
| 91 | allFiles.push(...files); |
| 92 | } |
| 93 | return allFiles; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Returns list of files in the comma-separated file named at --filelist. |
no test coverage detected