gitclone
Advanced tools
Comparing version 1.0.4 to 2.0.0
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 | ||
} |
131
package.json
{ | ||
"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 | ||
} | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Floating dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license
Found 1 instance in 1 package
0
100
1
131
1
14820
4
9
6
93
1
+ Addedcapture-spawn@^1.0.1
+ Addedcross-spawn@^5.0.0
+ Addedgitclone-defaults@^2.0.0
+ Addedlazy-cache@^2.0.1
+ Addedcapture-spawn@1.0.1(transitive)
+ Addedcross-spawn@5.1.0(transitive)
+ Addederror-base@0.2.0(transitive)
+ Addedgitclone-defaults@2.3.8(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-child-process@1.0.2(transitive)
+ Addedis-node-emitter@1.0.6(transitive)
+ Addedis-real-object@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addedlazy-cache@2.0.2(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedset-getter@0.1.1(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedminimist@*
- Removednative-or-another@*
- Removedsliced@*
- Removedextend-shallow@2.0.1(transitive)
- Removedminimist@1.2.8(transitive)
- Removednative-or-another@5.0.1(transitive)
- Removednative-promise@1.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsliced@1.0.1(transitive)
- Removedtry-catch-callback@2.0.2(transitive)