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

refactor!: remove package.json-based parserConfiguration #1460

Merged
merged 3 commits into from Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 0 additions & 7 deletions test/fixtures/configured-bin.js

This file was deleted.

5 changes: 4 additions & 1 deletion test/fixtures/no-extension
Expand Up @@ -4,4 +4,7 @@

var parser = require('../../yargs.js')(process.argv.slice(2))

console.log(parser.argv)
console.log(parser.parserConfiguration({
'dot-notation': false,
'boolean-negation': false
}).argv)
5 changes: 4 additions & 1 deletion test/fixtures/no-require-main.js
Expand Up @@ -7,4 +7,7 @@ delete require.main

var parser = require('../../yargs.js')(process.argv.slice(2), undefined, require)

console.log(parser.argv)
console.log(parser.parserConfiguration({
'dot-notation': false,
'boolean-negation': false
}).argv)
6 changes: 5 additions & 1 deletion test/fixtures/normal-bin.js
@@ -1,6 +1,10 @@
#!/usr/bin/env node
var argv = require('./yargs/index.js')
var argv = require('../../index.js')
.help('help')
.version()
.parserConfiguration({
'dot-notation': false,
'boolean-negation': false
})
.argv
console.log(argv)
4 changes: 0 additions & 4 deletions test/fixtures/package.json
Expand Up @@ -2,9 +2,5 @@
"version": "9.9.9",
"repository": {
"type": "svn"
},
"yargs": {
"dot-notation": false,
"boolean-negation": false
}
}
4 changes: 4 additions & 0 deletions test/fixtures/symlink-bin.js
Expand Up @@ -2,5 +2,9 @@
var argv = require('./yargs-symlink/index.js')
.help('help')
.version()
.parserConfiguration({
'dot-notation': false,
'boolean-negation': false
})
.argv
console.log(argv)
12 changes: 0 additions & 12 deletions test/integration.js
Expand Up @@ -191,18 +191,6 @@ describe('integration tests', () => {
return done()
})
})

it('is overridden by yargs.parserConfiguration', (done) => {
testCmd('./configured-bin.js', [ '--foo.bar', '--no-baz' ], (code, stdout) => {
if (code) {
return done(new Error(`cmd exited with code ${code}`))
}

stdout.should.not.match(/foo\.bar/)
stdout.should.match(/noBaz/)
return done()
})
})
})

after(() => {
Expand Down
10 changes: 2 additions & 8 deletions yargs.js
@@ -1,4 +1,5 @@
'use strict'

const argsert = require('./lib/argsert')
const fs = require('fs')
const Command = require('./lib/command')
Expand Down Expand Up @@ -603,7 +604,7 @@ function Yargs (processArgs, cwd, parentRequire) {

const demand = opt.demand || opt.required || opt.require

// deprecated, use 'demandOption' instead
// A required option can be specified via "demand: true".
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth the disruption that dropping this feature would cause.

if (demand) {
self.demand(key, demand)
}
Expand Down Expand Up @@ -1032,13 +1033,6 @@ function Yargs (processArgs, cwd, parentRequire) {
options.__ = y18n.__
options.configuration = self.getParserConfiguration()

// Deprecated
let pkgConfig = pkgUp()['yargs']
if (pkgConfig) {
console.warn('Configuring yargs through package.json is deprecated and will be removed in a future major release, please use the JS API instead.')
options.configuration = Object.assign({}, pkgConfig, options.configuration)
}

const parsed = Parser.detailed(args, options)
let argv = parsed.argv
if (parseContext) argv = Object.assign({}, argv, parseContext)
Expand Down