Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
;
if (error._babel) {
console.log(
`\nCompile error: ${fileRelative}\n` +
excerpt({
line, column,
contents: fs.readFileSync(fileName),
}) + '\n' + cc.red(message.trim())
);
}
else {
// try to determine if it's a local file (as opposed to a builtin)
if (
fileName && (
isAbsolute(fileName) || (
builtins.indexOf(path.basename(fileName, '.js')) === -1 &&
pathExists.sync(path.resolve(cwd, fileName))
)
)
) {
console.log(
`\nRuntime error: ${fileRelative}\n` +
excerpt({
line, column,
contents: fs.readFileSync(fileName),
}) + '\n'
);
}
console.log(
cc.red(message.trim()) + '\n' +
return stackTrace.parse(error).map(call => {
const fileName = call.getFileName();
const functionName = call.getFunctionName();
const lineNumber = call.getLineNumber();
const columnNumber = call.getColumnNumber();
if (isString(fileName)) {
const absolute = isAbsolute(fileName);
const resolvedFileName = path.resolve(cwd, fileName);
if (
subdir(cwd, fileName) &&
!subdir(path.join(cwd, 'node_modules'), resolvedFileName) &&
(absolute || (
builtins.indexOf(path.basename(fileName, '.js')) === -1 &&
pathExists.sync(resolvedFileName)
))
) {
// absolute and within CWD (but not in node_modules folder)
// - highlight this line
return (
(functionName ? grey(' at ') + functionName : ' ') +
grey(' in ') + path.join('./', path.relative(cwd, fileName)) +
(lineNumber ? grey(':' + lineNumber + ':' + columnNumber) : '')