MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / jsOrTsFiles

Function jsOrTsFiles

packages/cli/generators/copyright/fs.js:24–42  ·  view source on GitHub ↗

* List all JS/TS files * @param {string[]} paths - Paths to search

(cwd, paths = [])

Source from the content-addressed store, hash-verified

22 * @param {string[]} paths - Paths to search
23 */
24async 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
44exports.FSE = defaultFS;
45exports.jsOrTsFiles = jsOrTsFiles;

Callers 1

Calls 1

testMethod · 0.45

Tested by

no test coverage detected