modarb-be / src /lib /utils /calling-file.helper.ts
moahmedwafy's picture
feat: get call file name
d86b75d
raw
history blame contribute delete
391 Bytes
export function getCallingFileName(): string {
try {
const error = new Error();
const callerFile = error.stack?.split('\n')[3].trim().replace(/^at /, '');
const insidePerantheses = callerFile?.match(/\(([^)]+)\)/)?.[1];
const getOnlyfilePaths = insidePerantheses?.split(':')[0]
return getOnlyfilePaths;
} catch (error) {
console.error(error)
return '';
}
}