npm-username
Advanced tools
Comparing version 0.0.1 to 0.0.2
41
index.js
@@ -0,28 +1,29 @@ | ||
#!/usr/bin/env node | ||
var request = require('request'); | ||
if(process.argv[2]) { | ||
checkCredentials(process.argv[2]); | ||
if (process.argv[2]) { | ||
checkCredentials(process.argv[2]); | ||
} else { | ||
console.log('Please enter a name.'); | ||
process.exit(0); | ||
} | ||
else { | ||
console.log('Please enter a name.'); | ||
process.exit(0); | ||
} | ||
function checkCredentials(username) { | ||
var req = { | ||
url : 'https://www.npmjs.com/~'+username | ||
} | ||
request(req, function(err, resp, body) { | ||
if(err) | ||
console.log('Some error occured in searching your username.'); | ||
else { | ||
if(resp.statusCode === 200) | ||
console.log('The username already exists :('); | ||
else if(resp.statusCode === 404 || resp.statusCode === 500) | ||
console.log('The username is available :)'); | ||
else | ||
console.log('Existence of the username could not be determined by this module. Sorry :(') | ||
var req = { | ||
url: 'https://www.npmjs.com/~' + username | ||
} | ||
}); | ||
request(req, function(err, resp, body) { | ||
if (err) | ||
console.log('Some error occured in searching your username.'); | ||
else { | ||
if (resp.statusCode === 200) | ||
console.log('The username already exists :('); | ||
else if (resp.statusCode === 404 || resp.statusCode === 500) | ||
console.log('The username is available :)'); | ||
else | ||
console.log('Existence of the username could not be determined by this module. Sorry :(') | ||
} | ||
}); | ||
} |
{ | ||
"name": "npm-username", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Check availability of username in npm", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# npm-username | ||
Check the availability of npm username | ||
Check the availability of npm username. Comes in handy when doing ```npm adduser``` | ||
## Install | ||
``` | ||
$ npm install npm-username -g | ||
``` | ||
## Usage | ||
``` | ||
$ npm-username '<username>' | ||
``` | ||
## Example | ||
``` | ||
$ npm-username 'jsmith' | ||
$ The username already exists :( | ||
``` |
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
3414
22