
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A library that contains different methods to be consumed by a node module
To install, simply run
> npm install --save git-lib
To use, require it by
var git = require("git-lib");
haveFilesToCommit
add
getCurrentBranch
showFilesAdded
showFilesModified
commit
revert
isGit
isGitSync
getFilesCached
getBranches
both remote and localnewBranch
checkout
both remote and localdeleteBranch
deleteBranches
Resolves if current directory has files to commit, throws if it doesn't
git.haveFilesToCommit().then(function(){
/** there are files to commit **/
}).catch(function(err){
if (err === "There are no files to commit"){
/** there are no files to commit **/
}
else {
/** some error has occured **/
}
});
Attempts to git add a file
git.add("example.file").then(function(){
/** successfully added **/
}).catch(function(err){
/** unsuccessful **/
});
Gets the name of the directory's current branch
git.getCurrentBranch().then(function(branchname){
/** branchname has the name of current branch **/
}).catch(function(err){
/** throws an error **/
});
Show files that has already been added
git.showFilesAdded().then(function(filesAdded){
/** filesAdded shows, in a string, a list of files added **/
}).catch(function(err){
/** throws an error**/
});
Show files in current directory that has been modified (and probably needs to be commited)
git.showFilesModified().then(function(modifiedFiles){
/** modifiedFiles is an array of files that has been modified **/
}).catch(function(err){
/** throws an error **/
});
Commits with a string of message and a string of options
git.commmit("message to commit", "--force").then(function(){
/** commit successful **/
}).catch(function(err){
/** throws an error **/
});
Takes an array of files, or a string of only one file, and reverts them
git.revert(["file1","file2"]).then(function(){
/** successfully reverted **/
}).catch(function(err){
/** throws an error **/
});
Determines if current directory has git initialized
git.isGit().then(function(){
/** has git initialized **/
}).catch(function(err){
/** doesn't have git initialized, and err displays that **/
});
A synchronous version of isGit
, so it can be used in an if statement
if (git.isGitSync()){
/** has git initialized **/
}
else {
/** doesn't have git initialized **/
}
Show files that are cached, which are also files that are added
git.getFilesCached().then(function(files){
/** files is an array list of files that has been added **/
}).catch(function(err){
/** throws an error **/
});
Local
Returns all local branches for the current git repository
git.getBranches.local().then(function(branches){
/** branches is an array of local branches **/
}).catch(function(error){
/** throws an error **/
});
all
Returns all branches, including remote, for the current git repository
git.getBranches.all().then(function(branches){
/** branches is an array of all branches **/
}).catch(function(error){
/** throws an error **/
});
Changes into branch thisBranch, where thisBranch is passed into the function
git.checkout("thisBranch").then(function(){
/** successfully checked out into branch *thisBranch* **/
}).catch(function(err){
/** throws an error **/
});
Creates new branch newBranch, where newBranch is passed into the function
git.newBranch("newBranch").then(function(){
/** new branch *newBranch* was successfully created **/
}).catch(function(err){
/** throws an error **/
});
Deletes branch thisbranch, where thisbranch is passed into the function
git.deleteBranch("thisbranch").then(function(){
/** new branch *thisbranch* was successfully deleted**/
}).catch(function(err){
/** throws an error **/
});
Delete multiple branches, using deleteBranch
. The array passed into the function is the array of a list of branches to delete
git.deleteBranches(/** array of branches name **/).then(function(result){
/** result = { success: [ all the successfully deleted branches ], failure: [ all the branches that failed to be deleted ] } **/
});
1.6.0
1.5.0
1.4.0
1.3.1
1.3.0
1.2.3
1.2.2
1.2.1
1.2.0
1.1.0
1.0.0
FAQs
A github library for multiple package uses
The npm package git-lib receives a total of 2 weekly downloads. As such, git-lib popularity was classified as not popular.
We found that git-lib 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.