* List all JS/TS files * @param {string[]} paths - Paths to search
(cwd, paths = [])
| 22 | * @param {string[]} paths - Paths to search |
| 23 | */ |
| 24 | async function jsOrTsFiles(cwd, paths = []) { |
| 25 | paths = [].concat(paths); |
| 26 | let globs; |
| 27 | if (paths.length === 0) { |
| 28 | globs = [glob('**/*.{js,ts}', {nodir: true, follow: false, cwd})]; |
| 29 | } else { |
| 30 | globs = paths.map(p => { |
| 31 | if (/\/$/.test(p)) { |
| 32 | p += '**/*.{js,ts}'; |
| 33 | } else if (!/[^*]\.(js|ts)$/.test(p)) { |
| 34 | p += '/**/*.{js,ts}'; |
| 35 | } |
| 36 | return glob(p, {nodir: true, follow: false, cwd}); |
| 37 | }); |
| 38 | } |
| 39 | paths = await Promise.all(globs); |
| 40 | paths = _.map(_.flatten(paths), pathString => pathString.replace(/\\/g, '/')); |
| 41 | return _.filter(paths, /\.(js|ts)$/); |
| 42 | } |
| 43 | |
| 44 | exports.FSE = defaultFS; |
| 45 | exports.jsOrTsFiles = jsOrTsFiles; |
no test coverage detected