Comparing version 1.0.3 to 1.0.4
@@ -33,4 +33,4 @@ #!/usr/bin/env node | ||
proc.on('exit', function (code) { | ||
if (code != 0) {console.error(code)} | ||
if (code !== 0) {console.error(code)} | ||
process.exit(code) | ||
}) |
@@ -0,1 +1,8 @@ | ||
## v1.0.4 / November 11, 2014 | ||
- fix `-b`|`--branch`, not works | ||
- normalize dotfiles & package.json | ||
- add `sliced` as dep because of "*This function has too many parameters. (4)*", LOL ;p | ||
- add doc comments | ||
- add `jshint` as devDep | ||
## v1.0.3 / November 4, 2014 | ||
@@ -2,0 +9,0 @@ - my style-guide driven changes at all |
22
index.js
@@ -15,10 +15,20 @@ /** | ||
var spawn = require('child_process').spawn; | ||
var Promise = require('native-or-another'); | ||
var Promize = require('native-or-another'); | ||
var gitclone = require('./lib/gitclone'); | ||
var slice = require('sliced'); | ||
module.exports = function gitClone(repository, destination, branch, ssh) { | ||
var args = [].slice(arguments,0) | ||
var flags = gitclone(repository, destination, branch, ssh)[0]; | ||
/** | ||
* 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]; | ||
return new Promise(function(resolve, reject) { | ||
return new Promize(function(resolve, reject) { | ||
var proc = spawn('git', flags, { | ||
@@ -31,3 +41,3 @@ stdio: 'inherit' | ||
proc.on('exit', function (code) { | ||
if (code != 0) {reject(code)} | ||
if (code !== 0) {reject(code)} | ||
else {resolve(flags)} | ||
@@ -34,0 +44,0 @@ process.exit(code) |
@@ -10,12 +10,31 @@ /** | ||
module.exports = function gitClone(repository, destination, branch, ssh) { | ||
var url = ssh ? 'git@github.com:' : 'https://github.com/' | ||
url = url + repository + '.git'; | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var slice = require('sliced'); | ||
/** | ||
* Clone Github repository for the given `username/repo` | ||
* | ||
* @param {String} `repository` | ||
* @param {String} `destination` | ||
* @param {String} `branch` | ||
* @param {Boolean} `ssh` | ||
* @return {String} command to execute | ||
*/ | ||
module.exports = function gitClone() { | ||
var args = slice(arguments) | ||
var url = args[3] ? 'git@github.com:' : 'https://github.com/' | ||
url = url + args[0] + '.git'; | ||
var command = ['clone', url]; | ||
if (destination) {command.push(destination)} | ||
if (branch) {command.concat(['-b', branch])} | ||
if (args[1]) {command.push(args[1])} | ||
if (args[2]) { | ||
command.push('-b') | ||
command.push(args[2]) | ||
} | ||
return [command, repository, destination, branch, ssh]; | ||
return [command, args[0], args[1], args[2]]; | ||
} |
{ | ||
"name": "gitclone", | ||
"version": "1.0.3", | ||
"description": "Clone a Github repository with only `username/repo`. Support CLI.", | ||
"version": "1.0.4", | ||
"description": "Clone a Github repository with only `username/repo`. Support CLI and Promise.", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "jshint ./**/*.js", | ||
"test": "node test/test.js" | ||
"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" | ||
}, | ||
@@ -31,10 +32,16 @@ "author": { | ||
"repo", | ||
"repository" | ||
"repository", | ||
"promise", | ||
"promises", | ||
"promises-aplus", | ||
"Promises/A+" | ||
], | ||
"dependencies": { | ||
"minimist": "*", | ||
"native-or-another": "*" | ||
"native-or-another": "*", | ||
"sliced": "*" | ||
}, | ||
"devDependencies": { | ||
"micropromise": "*" | ||
"micropromise": "*", | ||
"jshint": "*" | ||
}, | ||
@@ -41,0 +48,0 @@ "licenses": [{ |
# gitclone [![NPM version][npmjs-shields]][npmjs-url] [![Build Status][travis-img]][travis-url] [![Dependency Status][depstat-img]][depstat-url] | ||
> Clone a Github repository with only `username/repo` and support options | ||
> Clone a Github repository with only `username/repo` and support options. | ||
Support CLI and Promise. | ||
@@ -36,2 +37,3 @@ ## Install [![Nodei.co stats][npmjs-install]][npmjs-url] | ||
//gitclone(repository, destination, branch, ssh) | ||
var clone = gitclone('tunnckoCore/week-seconds') | ||
@@ -41,3 +43,3 @@ | ||
.then(function(res) { | ||
//=> res == [command, repository, destination, branch, ssh] | ||
//=> res == [command, repository, destination, branch] | ||
assert(res[1] === 'tunnckoCore/week-seconds') //repository | ||
@@ -44,0 +46,0 @@ }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96
15633
3
2
14
121
4
+ Addedsliced@*
+ Addedsliced@1.0.1(transitive)