Node.js Reporters
Reporters handle what happens when an approval fails.
Contents
Available Reporters
Pass as strings to reporters config:
Diff tools: BeyondCompare, diffmerge, p4merge, tortoisemerge, meld, kdiff3, vimdiff
Editors: vscode, vscodium, visualstudio
Console: nodediff, gitdiff
CI-friendly: copycommand (outputs copy command), donothing (silent fail)
approvals.configure({
reporters: ['BeyondCompare', 'vscode', 'gitdiff']
});MultiReporter
Try reporters in order until one works:
const { MultiReporter } = approvals.reporters;
approvals.configure({
reporters: [new MultiReporter(['p4merge', 'vscode', 'copycommand'])]
});Custom Reporter
approvals.configure({
reporters: [{
name: 'my-reporter',
canReportOn: (filePath) => true,
report: (approvedPath, receivedPath) => {
console.log(`Diff: ${approvedPath} vs ${receivedPath}`);
}
}]
});Interface:
name- Reporter identifiercanReportOn(filePath)- Return true if reporter can handle this filereport(approvedPath, receivedPath)- Handle the mismatch