MCPcopy Create free account
hub / github.com/ampproject/amphtml / shouldTriggerAva

Function shouldTriggerAva

build-system/tasks/ava.js:29–38  ·  view source on GitHub ↗

* Determines whether to trigger ava by a file change adjacent to a test file. * Considered adjacent when the file changed is in the same directory as one of * the listed test files, or its parent if the directory is named `test`. * @param {string} changedFile * @return {boolean}

(changedFile)

Source from the content-addressed store, hash-verified

27 * @return {boolean}
28 */
29function shouldTriggerAva(changedFile) {
30 if (!targetFiles) {
31 const thisFile = relative(process.cwd(), __filename);
32 const patterns = testFiles.map(
33 (pattern) => dirname(pattern).replace(/\/test$/, '') + '/'
34 );
35 targetFiles = new Set([thisFile, ...globbySync(patterns)]);
36 }
37 return targetFiles.has(changedFile);
38}
39
40/**
41 * Runs ava tests.

Callers 1

build-targets.jsFile · 0.85

Calls 2

replaceMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected