Skip to content

Commit f1fbf09

Browse files
committed
refactor: wip
1 parent 2fae769 commit f1fbf09

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

packages/plugin-knip/src/lib/reporter/reporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function saveRawReport(
4242
*
4343
* @example
4444
* run the following command to test it:
45-
* npx knip --reporter ./dist/packages/plugin-knip/reporter.js --reporter-options='{\"outputFile\":\"my-knip-report.json\"}'
45+
* npx knip --reporter ./dist/packages/plugin-knip/reporter.js --reporter-options='{"outputFile":"my-knip-report.json"}'
4646
*
4747
*/
4848
export const knipReporter = async (knipReporterOptions: ReporterOptions) => {

packages/plugin-knip/src/lib/runner/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ export function createRunnerConfig(options: RunnerOptions = {}): RunnerConfig {
6464
'--no-progress',
6565
// code-pushup reporter is used from the installed package
6666
`--reporter=${reporterPath}`,
67-
// code-pushup reporter options are passed as string. See
68-
`--reporter-options='${JSON.stringify({
69-
outputFile,
70-
rawOutputFile,
71-
} satisfies CustomReporterOptions)}'`,
67+
// code-pushup reporter options are passed as string. Double JSON.stringify ensures proper escaping on all platforms
68+
`--reporter-options=${JSON.stringify(
69+
JSON.stringify({
70+
outputFile,
71+
rawOutputFile,
72+
} satisfies CustomReporterOptions),
73+
)}`,
7274
],
7375
outputFile,
7476
};

0 commit comments

Comments
 (0)