Comparing version
35
cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
var pkg = require('./package.json'); | ||
var meow = require('meow'); | ||
var fullname = require('./'); | ||
var argv = process.argv.slice(2); | ||
function help() { | ||
console.log([ | ||
'', | ||
' ' + pkg.description, | ||
'', | ||
' Example', | ||
' fullname', | ||
' Sindre Sorhus' | ||
].join('\n')); | ||
} | ||
meow({ | ||
help: [ | ||
'Example', | ||
' $ fullname', | ||
' Sindre Sorhus' | ||
] | ||
}); | ||
if (argv.indexOf('--help') !== -1) { | ||
help(); | ||
return; | ||
} | ||
fullname(function (err, name) { | ||
if (err) { | ||
console.error(err.message); | ||
process.exit(1); | ||
} | ||
if (argv.indexOf('--version') !== -1) { | ||
console.log(pkg.version); | ||
return; | ||
} | ||
fullname(function (err, name) { | ||
console.log(name); | ||
}); |
@@ -84,3 +84,3 @@ 'use strict'; | ||
exec('getent passwd $(whoami)', function (err, stdout) { | ||
fullname = stdout.trim().split(':')[4].replace(/,.*/, ''); | ||
fullname = (stdout.trim().split(':')[4] || '').replace(/,.*/, ''); | ||
@@ -87,0 +87,0 @@ if (err || !fullname) { |
{ | ||
"name": "fullname", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Get the fullname of the current user", | ||
@@ -10,7 +10,5 @@ "license": "MIT", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
"url": "sindresorhus.com" | ||
}, | ||
"bin": { | ||
"fullname": "cli.js" | ||
}, | ||
"bin": "cli.js", | ||
"engines": { | ||
@@ -27,2 +25,3 @@ "node": ">=0.10.0" | ||
"keywords": [ | ||
"cli-app", | ||
"cli", | ||
@@ -46,2 +45,3 @@ "bin", | ||
"dependencies": { | ||
"meow": "^3.3.0", | ||
"npmconf": "^2.1.1" | ||
@@ -48,0 +48,0 @@ }, |
@@ -39,3 +39,3 @@ # fullname [](https://travis-ci.org/sindresorhus/fullname) | ||
Example | ||
fullname | ||
$ fullname | ||
Sindre Sorhus | ||
@@ -42,0 +42,0 @@ ``` |
4891
-3.3%2
100%97
-7.62%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added