get-pkg-repo
Advanced tools
Comparing version 0.0.3 to 0.0.4
49
cli.js
@@ -14,4 +14,4 @@ #!/usr/bin/env node | ||
'Examples', | ||
' get-pkg-repo', | ||
' get-pkg-repo bitbucket.org/a/b.git', | ||
'', | ||
' cat package.json | get-pkg-repo --fix-typo' | ||
@@ -23,14 +23,43 @@ ].join('\n') | ||
if (cli.input.length > 0) { | ||
forEach(cli.input, function(repo) { | ||
var pkgData = { | ||
repository: repo | ||
}; | ||
console.log(getPkgRepo(pkgData, flags.fixTypo)); | ||
}); | ||
if (process.stdin.isTTY) { | ||
if (cli.input[0]) { | ||
forEach(cli.input, function(repo) { | ||
var url; | ||
var pkgData = { | ||
repository: repo | ||
}; | ||
try { | ||
url = getPkgRepo(pkgData, flags.fixTypo, flags.warn); | ||
console.log(url); | ||
} catch (e) { | ||
console.error(e.toString()); | ||
} | ||
}); | ||
} else { | ||
process.stdin | ||
.pipe(through(function(chunk, enc, callback) { | ||
var url; | ||
var pkgData = { | ||
repository: chunk.toString() | ||
}; | ||
try { | ||
url = getPkgRepo(pkgData, flags.fixTypo, flags.warn); | ||
callback(null, url + '\n'); | ||
} catch (e) { | ||
console.error(e.toString()); | ||
callback(null); | ||
} | ||
})) | ||
.pipe(process.stdout); | ||
} | ||
} else { | ||
process.stdin | ||
.pipe(through(function(chunk, enc, callback) { | ||
var url = getPkgRepo(chunk.toString(), flags.fixTypo, flags.warn); | ||
var url; | ||
try { | ||
url = getPkgRepo(chunk.toString(), flags.fixTypo, flags.warn); | ||
} catch (e) { | ||
console.error(e.toString()); | ||
process.exit(1); | ||
} | ||
callback(null, url + '\n'); | ||
@@ -37,0 +66,0 @@ })) |
@@ -20,3 +20,3 @@ 'use strict'; | ||
} catch (e) { | ||
return ''; | ||
throw new Error('Cannot parse non Github Url'); | ||
} | ||
@@ -51,3 +51,3 @@ } | ||
if (typeof url !== 'string') { | ||
return ''; | ||
throw new Error('Cannot get repository'); | ||
} | ||
@@ -54,0 +54,0 @@ |
{ | ||
"name": "get-pkg-repo", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Get repository url from package json data", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/stevemao/get-pkg-repo", |
@@ -64,5 +64,13 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverall-image]][coverall-url] | ||
You can use cli to see what your url will look like after being parsed. You can write more than one repository urls at a time. | ||
You can use cli to see what your url will look like after being parsed. | ||
You can enter interactive mode by typing | ||
```sh | ||
$ get-pkg-repo | ||
``` | ||
You can use the command followed by a url. You can write more than one repository urls at a time. | ||
```sh | ||
$ npm install --global get-pkg-repo | ||
@@ -69,0 +77,0 @@ $ get-pkg-repo bitbucket.org/a/b.git |
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
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
6582
112
100