Skip to content

Instantly share code, notes, and snippets.

@mattpocock
Created May 22, 2019 12:35
Show Gist options
  • Select an option

  • Save mattpocock/f4f1f2eb449302d983498126ac0232e6 to your computer and use it in GitHub Desktop.

Select an option

Save mattpocock/f4f1f2eb449302d983498126ac0232e6 to your computer and use it in GitHub Desktop.
Running jsinspect with an accepted number of errors
const { execSync } = require('child_process');
const path = require('path');
const pathToInspect = path.resolve(__dirname, '../../../app');
const acceptedNumberOfErrors = 0;
console.log(`Running jsinspect with accepted number of errors: ${acceptedNumberOfErrors}`)
try {
execSync(`jsinspect ${pathToInspect} -r json`);
process.exit();
} catch(e) {
const output = e.stdout.toString();
const parsedOutput = JSON.parse(output);
if (parsedOutput.length && parsedOutput.length > acceptedNumberOfErrors) {
console.log('Found errors:')
console.log(JSON.stringify(parsedOutput, null, 2));
process.exit(2);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment