-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (29 loc) · 920 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const globby = require('globby');
const path = require('path');
function detectRepoTestFiles(dir) {
const globbyOptions = {
cwd: dir,
// Ignore node_modules
ignore: ['node_modules/**'],
// Only return files
onlyFiles: true,
// Case insensitive
nocase: true,
// Ignore symlinks to avoid loops
followSymlinkedDirectories: false,
// Return absolute paths
absolute: true,
};
return globby([
// Conventional test dirs (including deep)
'**/{test,spec}?(s)/**/*',
// Suffix-style test files (foo-test.*, foo.test.*, foo_test.*)
'**/*[._-]{test,spec}?(s).*',
// Conventional root test files
'**/{test,spec}?(s).*',
// React/Jest style test files
'**/_?(_){test,spec}?(s)?(_)_/**/*',
], globbyOptions);
}
module.exports = detectRepoTestFiles;