Socket
Socket
Sign inDemoInstall

gitclone

Package Overview
Dependencies
21
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 2.0.0

CHANGELOG.md

107

index.js

@@ -1,45 +0,86 @@

/**
/*!
* gitclone <https://github.com/tunnckoCore/gitclone>
*
* Copyright (c) 2014 Charlike Mike Reagent, contributors.
* Copyright (c) 2014-2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
'use strict';
'use strict'
var utils = require('./utils')
/**
* Module dependencies.
* > Clones github repository, optionally
* pass destination folder. By defaults uses HTTPS
* to clone the repository. If you want SSH clone
* you should pass second, third or fourth argument
* boolean `true`, or object `{ssh: true}`.
* Pattern can be `user/repo#branch` as first
* argument. Or first argument `user`, second
* argument `repo`, third `branch`, fourth `ssh`.
*
* **Hint:** All arguments are super flexible and they are handled
* absolutely directly with [gitclone-defaults][],
* so read its [API docs](https://github.com/tunnckoCore/gitclone-defaults#api).
* In addition, you also can pass `callback` as last argument, otherwise
* it will return Spawn stream.
*
* **Example**
*
* ```js
* const gitclone = require('gitclone')
*
* // clones with SSH
* gitclone('node-minibase/minibase', true)
*
* // clone with HTTPS
* gitclone('node-minibase/minibase', (err) => {
* if (err) return console.error(err)
* })
*
* // clone `dev` branch from `verbose/verb` repo
* gitclone('verbose/verb#dev', console.log)
*
* // clone `jonschlinkert/nanomatch` with SSH
* gitclone('jonchlinkert', 'nanomatch', true)
*
* // clone to different destination folder
* gitclone('hybridables/always-done', { dest: 'foobar' })
*
* // clone SSH + dest + branch
* gitclone('verbose/verb', { dest: 'verb0.9.0', branch: 'dev', ssh: true })
* ```
*
* @param {Function} `[callback]` optional, if not given, returns a stream
* @return {Stream} if not `callback` given as last argument - a Spawn stream
* @api public
*/
var spawn = require('child_process').spawn;
var Promize = require('native-or-another');
var gitclone = require('./lib/gitclone');
var slice = require('sliced');
module.exports = function gitclone () {
var argz = [].slice.call(arguments)
var cb = argz[argz.length - 1]
var opts = utils.gitcloneDefaults.apply(this, argz)
var args = ['clone']
var param = opts.ssh ? 'git@github.com:' : 'https://github.com/'
/**
* Clone Github repository for the given `username/repo`
*
* @param {String} `repository`
* @param {String} `destination`
* @param {String} `branch`
* @param {Boolean} `ssh`
* @return {Promise}
*/
module.exports = function gitClone() {
var args = slice(arguments);
var flags = gitclone(args[0], args[1], args[2], args[3])[0];
args.push(param + opts.repository + '.git')
return new Promize(function(resolve, reject) {
var proc = spawn('git', flags, {
stdio: 'inherit'
})
proc.on('error', function(err) {
reject(err)
})
proc.on('exit', function (code) {
if (code !== 0) {reject(code)}
else {resolve(flags)}
process.exit(code)
})
})
if (opts.branch !== 'master') {
args.push('-b')
args.push(opts.branch)
}
if (opts.dest) {
args.push(opts.dest)
}
gitclone.options = gitclone.options && typeof gitclone.options === 'object'
? gitclone.options
: { stdio: [null, null, null] }
var cp = utils.spawn('git', args, gitclone.options)
if (typeof cb === 'function') {
utils.capture(cp, cb)
return
}
return cp
}
{
"name": "gitclone",
"version": "1.0.4",
"description": "Clone a Github repository with only `username/repo`. Support CLI and Promise.",
"version": "2.0.0",
"description": "Powerful and flexible programmatic interface for the `git clone` command, using [gitclone-defaults][] and [cross-spawn][]",
"repository": "tunnckoCore/gitclone",
"author": "Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)",
"precommit.silent": true,
"main": "index.js",
"license": "MIT",
"scripts": {
"clean": "rm -rf node_modules week-seconds",
"lint": "npm run clean && npm install && jshint bin/*.js lib/*.js test/*.js index.js",
"test": "npm run lint && node test/test.js"
"lint": "standard --verbose",
"pretest": "npm run lint",
"test": "npm run coverage",
"posttest": "npm run lint:coverage",
"coverage": "nyc node test.js",
"lint:coverage": "nyc check-coverage --lines 0 --branches 0 --statements 0 --functions 0",
"report-coverage": "nyc report --reporter=text-lcov | coveralls",
"prerelease": "npm test",
"release": "standard-version --sign --no-verify",
"precommit": "git add --all",
"commit": "git-cz"
},
"author": {
"name": "Charlike Make Reagent",
"email": "mameto_100@mail.bg",
"url": "https://github.com/tunnckoCore",
"twitter": "https://twitter.com/tunnckoCore"
"dependencies": {
"capture-spawn": "^1.0.1",
"cross-spawn": "^5.0.0",
"gitclone-defaults": "^2.0.0",
"lazy-cache": "^2.0.1"
},
"repository": {
"type": "git",
"url": "git://github.com/tunnckoCore/gitclone.git"
"devDependencies": {
"commitizen": "^2.8.6",
"coveralls": "^2.11.14",
"cz-conventional-changelog": "^1.2.0",
"mukla": "^0.4.4",
"nyc": "^8.3.2",
"pre-commit": "^1.1.3",
"rimraf": "^2.5.4",
"standard": "^8.5.0",
"standard-version": "^3.0.0"
},
"files": [
"index.js",
"utils.js"
],
"keywords": [
"api",
"clone",
"cmd",
"command",
"flexible",
"gh",
"ghclone",
"git",
"cli",
"support",
"helper",
"gitc",
"gitclone",
"github",
"utils",
"utility",
"github-clone",
"interface",
"powerful",
"program",
"programmatic",
"ui",
"util",
"clone",
"repo",
"repository",
"promise",
"promises",
"promises-aplus",
"Promises/A+"
"utils"
],
"dependencies": {
"minimist": "*",
"native-or-another": "*",
"sliced": "*"
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"devDependencies": {
"micropromise": "*",
"jshint": "*"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/tunnckoCore/gitclone/blob/master/license.md"
}],
"engines": {
"node": ">= 0.10.0",
"npm": ">= 1.4.28"
},
"bin": {
"gitclone": "bin/cli.js"
},
"preferGlobal": "true"
"verb": {
"run": true,
"toc": true,
"layout": "empty",
"tasks": [
"readme"
],
"related": {
"list": [
"gitclone-defaults",
"try-catch-callback",
"try-catch-core",
"always-done",
"minibase"
]
},
"reflinks": [
"cross-spawn",
"gitclone-defaults",
"always-done",
"async-done",
"base",
"dezalgo",
"once",
"try-catch-core"
],
"lint": {
"reflinks": true
}
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc