UNPKG

poku

Version:

🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.

25 lines (24 loc) 688 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findFile = void 0; const regex = /at\s(\/.+|file:.+)|^(\s+)at\smodule\scode\s\((\/.+|file:.+)\)/i; const findFile = (error) => { const stackLines = error.stack?.split('\n') ?? []; let file = ''; const basePath = 'poku/lib/'; for (const line of stackLines) { if (line.indexOf(basePath) !== -1) continue; const match = line.match(regex); if (match?.[1]) { file = match[1]; break; } if (match?.[3]) { file = match[3]; break; } } return file; }; exports.findFile = findFile;