diff --git a/index.js b/index.js index dfed54bc5..25bde57d1 100644 --- a/index.js +++ b/index.js @@ -25,8 +25,10 @@ function singletonify (inst) { Object.keys(inst).forEach((key) => { if (key === 'argv') { Argv.__defineGetter__(key, inst.__lookupGetter__(key)) + } else if (typeof inst[key] === 'function') { + Argv[key] = inst[key].bind(inst) } else { - Argv[key] = typeof inst[key] === 'function' ? inst[key].bind(inst) : inst[key] + Argv.__defineGetter__(key, () => inst[key]) } }) } diff --git a/test/yargs.js b/test/yargs.js index 20f105850..66c5bf82e 100644 --- a/test/yargs.js +++ b/test/yargs.js @@ -837,6 +837,17 @@ describe('yargs dsl tests', () => { }) }) + describe('parsed', () => { + it('should be false before parsing', () => { + yargs.parsed.should.equal(false) + }) + + it('should not be false after parsing', () => { + yargs.parse() + yargs.parsed.should.not.equal(false) + }) + }) + // yargs.parse(['foo', '--bar'], function (err, argv, output) {} context('function passed as second argument to parse', () => { it('does not print to stdout', () => {