Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
get-caller-file
Advanced tools
Package description
The get-caller-file package is designed to help developers retrieve the path of the file that calls a function. This can be particularly useful for debugging, logging, or tracking the flow of execution in complex applications where functions might be called from various locations.
Getting the path of the caller file
This feature allows developers to easily identify the file path of the code that called a function. By using `getCallerFile` within a function, it logs the path of the file that initiated the call, aiding in debugging and tracking execution flow.
const getCallerFile = require('get-caller-file');
function someFunction() {
console.log(getCallerFile());
}
The 'callsites' package provides functionality similar to 'get-caller-file' by returning an array of call sites (stack frames), allowing developers to get more detailed information about the call stack. It offers a broader set of features for inspecting the call stack compared to the focused functionality of 'get-caller-file'.
The 'stack-trace' package is another alternative that allows users to capture and inspect stack traces. While 'get-caller-file' focuses on identifying the caller file, 'stack-trace' provides a more comprehensive set of tools for working with stack traces, including parsing, filtering, and formatting stack frames.
Readme
This is a utility, which allows a function to figure out from which file it was invoked. It does so by inspecting v8's stack trace at the time it is invoked.
Inspired by http://stackoverflow.com/questions/13227489
note: this relies on Node/V8 specific APIs, as such other runtimes may not work
yarn add get-caller-file
Given:
// ./foo.js
const getCallerFile = require('get-caller-file');
module.exports = function() {
return getCallerFile(); // figures out who called it
};
// index.js
const foo = require('./foo');
foo() // => /full/path/to/this/file/index.js
getCallerFile(position = 2)
: where position is stack frame whos fileName we want.FAQs
[![Build Status](https://travis-ci.org/stefanpenner/get-caller-file.svg?branch=master)](https://travis-ci.org/stefanpenner/get-caller-file) [![Build status](https://ci.appveyor.com/api/projects/status/ol2q94g1932cy14a/branch/master?svg=true)](https://ci.a
The npm package get-caller-file receives a total of 33,988,153 weekly downloads. As such, get-caller-file popularity was classified as popular.
We found that get-caller-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.