Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
fix: Don't write results into appmap index dir (which may not exist)
Browse files Browse the repository at this point in the history
Also report 'findings' to SCM rather than 'matches'
  • Loading branch information
kgilpin committed Oct 1, 2021
1 parent ab9f358 commit ff402cb
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Finding } from './types';
import { Argv, Arguments } from 'yargs';
import chalk from 'chalk';
import loadConfiguration from './configuration';
import { appMapDir, verbose } from './scanner/util';
import { verbose } from './scanner/util';
import { join } from 'path';
import { ideLink } from './scanner/util';
import postCommitStatus from './commitStatus/github/commitStatus';
Expand Down Expand Up @@ -188,30 +188,10 @@ export default {
);
console.log();

const appMapDirMatches: Record<string, Finding[]> = {};
findings.forEach((m) => {
const dirName = appMapDir(m.appMapFile!);
if (!appMapDirMatches[dirName]) {
appMapDirMatches[dirName] = [];
}
appMapDirMatches[dirName].push(m);
});

await Promise.all(
Object.keys(appMapDirMatches).map(async (appMapDir) => {
const matches = appMapDirMatches[appMapDir];
const matchList = matches.map((match) => ({
eventId: match.event.id,
scannerId: match.scannerId,
}));
return fs.writeFile(join(appMapDir, 'scan.json'), JSON.stringify(matchList, null, 2));
})
);

if (commitStatus) {
summary.matched === 0
? postCommitStatus('success', `${summary.unmatched} checks passed`)
: postCommitStatus('failure', `${summary.matched} checks failed`);
findings.length === 0
? postCommitStatus('success', `${files.length * assertions.length} checks passed`)
: postCommitStatus('failure', `${findings.length} findings`);
}

return process.exit(findings.length === 0 ? 0 : ExitCode.Finding);
Expand Down

0 comments on commit ff402cb

Please sign in to comment.