Open Janey2022 opened 1 year ago
It seems not a good approach. But still need to handle the issue when the loop exit in some cases.
How about throwing an exception in this case?
That way, we can catch the error with a try{} catch(){}
How about throwing an exception in this case?
That way, we can catch the error with a
try{} catch(){}
Good point, yes, if we use process.exit instead of exception, try catch can't catch process.exit(1). Should throw exception instead.
For those waiting for this to merge; we use the following monkey patch at work. 🐒
{
const old_exit = process.exit;
// @ts-ignore monkey patching
process.exit = () => {};
await scanner.run(/* ...code... */);
process.exit = old_exit;
}
With the origin logic, if I run it in the cases that contains several dirs, it will break when found one has no matched file to scan.