MCPcopy Index your code
hub / github.com/code-pushup/cli / formatPluginInit

Function formatPluginInit

packages/plugin-coverage/src/lib/binding.ts:181–207  ·  view source on GitHub ↗
(
  options: CoverageOptions,
  lcovConfigured: boolean,
)

Source from the content-addressed store, hash-verified

179}
180
181function formatPluginInit(
182 options: CoverageOptions,
183 lcovConfigured: boolean,
184): string[] {
185 const { reportPath, testCommand, types, continueOnFail } = options;
186
187 const hasCustomTypes =
188 types.length > 0 && types.length < ALL_COVERAGE_TYPES.length;
189
190 const body = [
191 `reports: [${singleQuote(reportPath)}],`,
192 testCommand
193 ? `coverageToolCommand: { command: ${singleQuote(testCommand)} },`
194 : '',
195 hasCustomTypes
196 ? `coverageTypes: [${types.map(singleQuote).join(', ')}],`
197 : '',
198 continueOnFail ? '' : 'continueOnCommandFail: false,',
199 ].filter(Boolean);
200
201 const init = [
202 'await coveragePlugin({',
203 ...body.map(line => ` ${line}`),
204 '}),',
205 ];
206 return lcovConfigured ? init : [LCOV_COMMENT, ...init];
207}
208
209async function isRecommended(targetDir: string): Promise<boolean> {
210 return (await detectFramework(targetDir)) !== 'other';

Callers 1

binding.tsFile · 0.70

Calls 1

singleQuoteFunction · 0.90

Tested by

no test coverage detected