Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function tsFileAssert(
fileName: string,
errType?: string | RegExp | Function,
message?: string | RegExp,
assertMethod = assert.throws
): Promise {
let typescriptConfig = await tsconfig.resolve(dirname(fileName));
let cb = () => {
check([fileName], typescriptConfig as string);
};
if (!errType) {
assertMethod(cb);
} else if (typeof errType === 'string') {
assertMethod(cb, errType);
} else if (message && typeof message === 'string') {
assertMethod(cb, errType, message);
} else if (errType instanceof Function && message instanceof RegExp) {
assertMethod(cb, errType, message);
} else {
assertMethod(cb, errType);
}
}