Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: context should override parsed argv #786

Merged
merged 1 commit into from Feb 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/yargs.js
Expand Up @@ -768,6 +768,14 @@ describe('yargs dsl tests', function () {
a1.foo.should.equal('bar')
a1.context.should.equal('look at me go!')
})

// see https://github.com/yargs/yargs/issues/724
it('overrides parsed value of argv with context object', function () {
var a1 = yargs.parse('-x=33', {
x: 42
})
a1.x.should.equal(42)
})
})

// yargs.parse(['foo', '--bar'], function (err, argv, output) {}
Expand Down
2 changes: 1 addition & 1 deletion yargs.js
Expand Up @@ -935,7 +935,7 @@ function Yargs (processArgs, cwd, parentRequire) {
options.configuration = pkgUp()['yargs'] || {}
const parsed = Parser.detailed(args, options)
var argv = parsed.argv
if (parseContext) argv = assign(parseContext, argv)
if (parseContext) argv = assign(argv, parseContext)
var aliases = parsed.aliases

argv.$0 = self.$0
Expand Down