it doesn't work with warning messages, but only errors.
Opened this issue · 1 comments
lucamjj commented
Is there a way I can pass this as a config param?
royriojas commented
Hi @lucamjj
This module uses the exit code of the process, so if the task you're executing can be configured to consider warnings as errors and exit with a code different than 0, then this will work.
Alternatively you can wrap the tool in a small wrapper and check if warnings were printed and then exit with non zero in that case. Something like the following:
import { exec } from 'child_process';
// exec a verify task in your package json
exec('npm run verify', (err, stdout, stderr) => {
// check here if stdout has warnings
if (stdout.match(/warning/) || err) {
process.exit(1);
return;
}
process.exit(0); // all other cases
});
Then you can use that as your prepush task