Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
current-git-branch
Advanced tools
The `current-git-branch` npm package is a simple utility that allows you to get the name of the current Git branch in a Node.js environment. It is useful for scripts and tools that need to be aware of the current branch context.
Get Current Git Branch
This feature allows you to retrieve the name of the current Git branch. The code sample demonstrates how to use the `current-git-branch` package to get the branch name and print it to the console.
const currentGitBranch = require('current-git-branch');
const branchName = currentGitBranch();
console.log(branchName);
The `git-branch` package provides similar functionality to `current-git-branch` by allowing you to get the current Git branch name. It also offers additional features like listing all branches and checking out a branch. Compared to `current-git-branch`, it is more feature-rich but also slightly more complex to use.
The `git-rev-sync` package offers a broader range of Git-related functionalities, including getting the current branch name, the latest commit hash, and the commit message. It is more comprehensive than `current-git-branch` but may be overkill if you only need to get the current branch name.
The `simple-git` package is a lightweight interface for running Git commands in a Node.js environment. It can be used to get the current branch name among many other Git operations. It is more versatile than `current-git-branch` but requires more setup and understanding of Git commands.
Get synchronously the current branch name
$ npm i current-git-branch --save
or
$ yarn add current-git-branch
Returns:
false
: It is not a git repositoryconst branchName = require('current-git-branch');
branchName(); // false or branch name of process.cwd()
branchName({ altPath: 'any/git/repo' }); // false or branch name of the directory 'any/git/repo'
branchName({ altPath: 'any/git/repo', branchOptions: [ "--no-color" ] }); // alternatively, you may pass git-branch command options, either as a string or an array
MIT © Jan Peer Stöcklmair
FAQs
A tool to check if files are added in a git repository
We found that current-git-branch 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.