Socket
Socket
Sign inDemoInstall

simple-git

Package Overview
Dependencies
Maintainers
1
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-git - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

test/examples/git-push-success.txt

2

package.json
{
"name": "simple-git",
"description": "Simple GIT interface for node.js",
"version": "0.2.0",
"version": "0.3.0",
"author": "Steve King <steve@mydev.co>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -40,2 +40,16 @@ # Simple Git

`.push(remote, branch, handlerFn)` pushes to a named remote and named branch
`.rm([fileA, ...], handlerFn)` removes any number of files from source control
`.rmKeepLocal([fileA, ...], handlerFn)` removes files from source control but leaves them on disk
`.addRemote(name, repo, handlerFn)` adds a new named remote to be tracked as `name` at the path `repo`
`.removeRemote(name, handlerFn)` removes the named remote
`.listRemote([args], handlerFn)` lists remote repositories - there are so many optional arguments in the underlying
`git ls-remote` call, just supply any you want to use as the optional `args` string.
# Examples

@@ -58,1 +72,12 @@

});
// starting a new repo
require('simple-git')()
.init()
.add('./*')
.commit("first commit!")
.addRemote('origin', 'https://github.com/user/repo.git')
.push('origin', 'master');

@@ -19,3 +19,2 @@ (function() {

*
* @param {Object} options
* @param {Function} [then]

@@ -31,2 +30,3 @@ */

* Internally uses pull and tags to get the list of tags then checks out the latest tag.
*
* @param {Function} [then]

@@ -58,3 +58,3 @@ */

* @param {String} message
* @param {String|String[]} files
* @param {String|String[]} [files]
* @param {Function} [then]

@@ -78,2 +78,3 @@ */

* Pull the updated contents of the current repo
*
* @param {Function} [then]

@@ -89,2 +90,3 @@ */

* List all tags
*
* @param {Function} [then]

@@ -100,2 +102,3 @@ */

* Check out a tag or revision
*
* @param {String} what

@@ -126,3 +129,3 @@ * @param {Function} [then]

*
* @param {String} args
* @param {String} [args]
* @param {Function} [then]

@@ -140,2 +143,78 @@ */

/**
* Adds a remote to the list of remotes.
*
* @param {String} remoteName Name of the repository - eg "upstream"
* @param {String} remoteRepo Fully qualified SSH or HTTP(S) path to the remote repo
* @param {Function} [then]
* @returns {*}
*/
Git.prototype.addRemote = function(remoteName, remoteRepo, then) {
return this._run('git remote add "' + remoteName + '" "' + remoteRepo + '"', function (err) {
then && then(err);
});
};
/**
* Removes an entry from the list of remotes.
*
* @param {String} remoteName Name of the repository - eg "upstream"
* @param {Function} [then]
* @returns {*}
*/
Git.prototype.removeRemote = function(remoteName, then) {
return this._run('git remote remove "' + remoteName + '"', function (err) {
then && then(err);
});
};
/**
* Pushes the current committed changes to a remote, optionally specify the names of the remote and branch to use
* when pushing.
*
* @param {String} [remote]
* @param {String} [branch]
* @param {Function} [then]
*/
Git.prototype.push = function(remote, branch, then) {
var command = "git push";
if (typeof remote === 'string' && typeof branch === 'string') {
command += ' "' + remote + '" "' + branch + '"';
}
if (typeof arguments[arguments.length - 1] === 'function') {
then = arguments[arguments.length - 1];
}
return this._run(command, function(err, data) {
then && then(err, !err && this._parsePush(data));
});
};
/**
* Removes the named files from source control.
*
* @param {String|String[]} files
* @param {Function} [then]
*/
Git.prototype.rm = function(files, then) {
return this._rm(files, '-f', then);
};
/**
* Removes the named files from source control but keeps them on disk rather than deleting them entirely. To
* completely remove the files, use `rm`.
*
* @param {String|String[]} files
* @param {Function} [then]
*/
Git.prototype.rmKeepLocal = function(files, then) {
return this._rm(files, '--cached', then);
};
Git.prototype._rm = function(files, options, then) {
return this._run('git rm ' + options + ' "' + [].concat(files).join('" "') + '"', function(err) {
then && then(err);
});
};
Git.prototype._parsePull = function(pull) {

@@ -142,0 +221,0 @@ var changes = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc