MCPcopy
hub / github.com/jestjs/jest / hasNativeFindSupport

Function hasNativeFindSupport

packages/jest-haste-map/src/crawlers/node.ts:24–57  ·  view source on GitHub ↗
(
  forceNodeFilesystemAPI: boolean,
)

Source from the content-addressed store, hash-verified

22type Callback = (result: Result) => void;
23
24async function hasNativeFindSupport(
25 forceNodeFilesystemAPI: boolean,
26): Promise<boolean> {
27 if (forceNodeFilesystemAPI) {
28 return false;
29 }
30
31 try {
32 return await new Promise(resolve => {
33 // Check the find binary supports the non-POSIX -iname parameter wrapped in parens.
34 const args = [
35 '.',
36 '-type',
37 'f',
38 '(',
39 '-iname',
40 '*.ts',
41 '-o',
42 '-iname',
43 '*.js',
44 ')',
45 ];
46 const child = spawn('find', args, {cwd: __dirname});
47 child.on('error', () => {
48 resolve(false);
49 });
50 child.on('exit', code => {
51 resolve(code === 0);
52 });
53 });
54 } catch {
55 return false;
56 }
57}
58
59function find(
60 roots: Array<string>,

Callers 1

nodeCrawlFunction · 0.85

Calls 2

onMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected