forked from webpro-nl/knip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
28 lines (21 loc) · 1.13 KB
/
index.ts
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
import { timerify } from '../../util/Performance.js';
import { hasDependency, load } from '../../util/plugin.js';
import type { StrykerConfig } from './types.js';
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
// https://stryker-mutator.io/docs/stryker-js/config-file/
export const NAME = 'Stryker';
/** @public */
export const ENABLERS = ['@stryker-mutator/core'];
export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
export const CONFIG_FILE_PATTERNS = ['?(.)stryker.{conf,config}.{js,mjs,cjs,json}'];
const findStrykerDependencies: GenericPluginCallback = async configFilePath => {
const config: StrykerConfig = await load(configFilePath);
if (config) {
const runners = config.testRunner ? [`@stryker-mutator/${config.testRunner}-runner`] : [];
const checkers = config.checkers ? config.checkers.map(checker => `@stryker-mutator/${checker}-checker`) : [];
const plugins = config.plugins ?? [];
return [...runners, ...checkers, ...plugins];
}
return [];
};
export const findDependencies = timerify(findStrykerDependencies);