tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-08-02 07:02:57 +03:00
parent 4c37f89150
commit 6731b64088
2 changed files with 15 additions and 7 deletions

20
argv.js
View File

@ -133,13 +133,17 @@ function(name, pre, post){
var getFromPackage =
module.extra.getFromPackage =
function(attr){
var dir = path.dirname((require.main || {}).filename || '.')
return function(path){
function(attr, func){
return function(p){
try {
return require(path
var res = require(p
|| this.packageJson
|| dir +'/package.json')[attr]
|| path.dirname(
(require.main || {}).filename || '.')
+'/package.json')[attr]
return func ?
func.call(this, res)
: res
} catch(err){
return undefined } } }
@ -524,7 +528,11 @@ object.Constructor('Parser', {
helpValueSeparator: '=',
// doc sections...
author: getFromPackage('author'),
author: getFromPackage('author',
function(o){
return typeof(o) != typeof('str') ?
Object.values(o).join(' ')
: o }),
license: getFromPackage('license'),
usage: '$SCRIPTNAME [OPTIONS]',
doc: undefined,

View File

@ -1,6 +1,6 @@
{
"name": "ig-argv",
"version": "2.10.1",
"version": "2.10.2",
"description": "simple argv parser",
"main": "argv.js",
"scripts": {