/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
build-system/tasks/ava.js
64 строки
2 KB
Daniel Rozenberg
🚮 Remove Bento from various CI tasks, build systems, docs, and examples (#38989)
25 май 2023, 20:04
Не верифицирован
25 май 2023, 20:04
a98a6f2
Код
Авторство
О чём код?
'use strict'; const argv = require('minimist')(process.argv.slice(2)); const {dirname, relative} = require('path'); const {execOrDie} = require('../common/exec'); const {sync: globbySync} = require('globby'); const testFiles = [ 'build-system/compile/generate/test/*.test.js', 'build-system/release-tagger/test/*test*.js', 'build-system/server/app-index/test/*test*.js', 'build-system/server/test/app-utils.test.js', 'build-system/tasks/get-zindex/get-zindex.test.js', 'build-system/tasks/make-extension/test/test.js', 'build-system/tasks/markdown-toc/test/test.js', 'build-system/tasks/prepend-global/prepend-global.test.js', 'build-system/tasks/remap-dependencies-plugin/test-remap-dependencies.js', ]; let targetFiles; /** * 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} */ function shouldTriggerAva(changedFile) { if (!targetFiles) { const thisFile = relative(process.cwd(), __filename); const patterns = testFiles.map( (pattern) => dirname(pattern).replace(/\/test$/, '') + '/' ); targetFiles = new Set([thisFile, ...globbySync(patterns)]); } return targetFiles.has(changedFile); } /** * Runs ava tests. * @return {Promise<void>} */ async function ava() { execOrDie( [ 'npx ava', ...testFiles, '--color --fail-fast', argv.watch ? '--watch' : '', ].join(' ') ); } module.exports = { ava, shouldTriggerAva, }; ava.description = "Run ava tests for AMP's tasks"; ava.flags = { 'watch': 'Watch for changes', };