How to catch runSync() exception
Hi, I want to catch 'exception' when TypeHelper throws exception. How I can do that ?
try{ testSync.runSync(); }catch(error) { console.log('error : '+ error); }
Thank-you
the throwOnError options just exits node process with error 1, not 0 (success), to make something like travis to react.
To know if error happend during sync the easier, to stop transpiling/nw build, just skip the throwOn options and check how many errors.
var TypeHelper = require('./dist/commonjs/index.js').TypeHelper
// sync run
let checkerSync = TypeHelper({
tsConfig: './tsconfig.json',
basePath: './',
tsLint: './tslint.json',
name: 'checkerSync'
});
let noErrors = checkerSync.runSync()
if (noErrors) {
console.log('on no, I have: ' + noErrors + ' errors');
} else {
console.log('all OK :-)');
}
@mickaelmartinsdev Does this help you issue ?
Documentation needs to be clearer for standard test cases
@vegarringdal actually this is a big issue now I'm trying to pipe error output to somewhere else.
Returning a number isn't enough, it should be an array of strings. If length 0, then 0 errors.
I didnt see this before now. We need to create a another function so we dont make a breaking change

added a getresult function
https://github.com/fuse-box/fuse-box-typechecker/blob/master/src/index.ts#L80-L83
please make a PR with edits to this function with the array data you would like to see
https://github.com/fuse-box/fuse-box-typechecker/blob/d9b9fbb71dd3277ccabfc8e1a6b78d8f6b5f465d/src/printResult.ts#L13-L58