Skip to content

Commit

Permalink
chore(deps): update dependency standard to v14 (#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] committed Feb 18, 2020
1 parent 1d4cca3 commit 996329b
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion lib/apply-extends.js
Expand Up @@ -20,7 +20,7 @@ function mergeDeep (config1, config2) {
const target = {}
const isObject = obj => obj && typeof obj === 'object' && !Array.isArray(obj)
Object.assign(target, config1)
for (let key of Object.keys(config2)) {
for (const key of Object.keys(config2)) {
if (isObject(config2[key]) && isObject(target[key])) {
target[key] = mergeDeep(config1[key], config2[key])
} else {
Expand Down
6 changes: 3 additions & 3 deletions lib/command.js
Expand Up @@ -443,16 +443,16 @@ module.exports = function command (yargs, usage, validation, globalMiddleware) {
// the state of commands such that
// we can apply .parse() multiple times
// with the same yargs instance.
let frozens = []
const frozens = []
self.freeze = () => {
let frozen = {}
const frozen = {}
frozens.push(frozen)
frozen.handlers = handlers
frozen.aliasMap = aliasMap
frozen.defaultCommand = defaultCommand
}
self.unfreeze = () => {
let frozen = frozens.pop()
const frozen = frozens.pop()
handlers = frozen.handlers
aliasMap = frozen.aliasMap
defaultCommand = frozen.defaultCommand
Expand Down
8 changes: 4 additions & 4 deletions lib/usage.js
Expand Up @@ -267,7 +267,7 @@ module.exports = function usage (yargs, y18n) {

// actually generate the switches string --foo, -f, --bar.
const switches = normalizedKeys.reduce((acc, key) => {
acc[key] = [ key ].concat(options.alias[key] || [])
acc[key] = [key].concat(options.alias[key] || [])
.map(sw => {
// for the special positional group don't
// add '--' or '-' prefix.
Expand Down Expand Up @@ -526,9 +526,9 @@ module.exports = function usage (yargs, y18n) {
return self
}

let frozens = []
const frozens = []
self.freeze = function freeze () {
let frozen = {}
const frozen = {}
frozens.push(frozen)
frozen.failMessage = failMessage
frozen.failureOutput = failureOutput
Expand All @@ -540,7 +540,7 @@ module.exports = function usage (yargs, y18n) {
frozen.descriptions = descriptions
}
self.unfreeze = function unfreeze () {
let frozen = frozens.pop()
const frozen = frozens.pop()
failMessage = frozen.failMessage
failureOutput = frozen.failureOutput
usages = frozen.usages
Expand Down
22 changes: 11 additions & 11 deletions lib/validation.js
Expand Up @@ -60,7 +60,7 @@ module.exports = function validation (yargs, usage, y18n) {
let missing = null

Object.keys(demandedOptions).forEach((key) => {
if (!argv.hasOwnProperty(key) || typeof argv[key] === 'undefined') {
if (!Object.prototype.hasOwnProperty.call(argv, key) || typeof argv[key] === 'undefined') {
missing = missing || {}
missing[key] = demandedOptions[key]
}
Expand Down Expand Up @@ -94,8 +94,8 @@ module.exports = function validation (yargs, usage, y18n) {

Object.keys(argv).forEach((key) => {
if (specialKeys.indexOf(key) === -1 &&
!positionalMap.hasOwnProperty(key) &&
!yargs._getParseContext().hasOwnProperty(key) &&
!Object.prototype.hasOwnProperty.call(positionalMap, key) &&
!Object.prototype.hasOwnProperty.call(yargs._getParseContext(), key) &&
!self.isValidAndSomeAliasIsNotNew(key, aliases)
) {
unknown.push(key)
Expand Down Expand Up @@ -149,12 +149,12 @@ module.exports = function validation (yargs, usage, y18n) {
// check for a key that is not an alias, or for which every alias is new,
// implying that it was invented by the parser, e.g., during camelization
self.isValidAndSomeAliasIsNotNew = function isValidAndSomeAliasIsNotNew (key, aliases) {
if (!aliases.hasOwnProperty(key)) {
if (!Object.prototype.hasOwnProperty.call(aliases, key)) {
return false
}
const newAliases = yargs.parsed.newAliases
for (let a of [key, ...aliases[key]]) {
if (!newAliases.hasOwnProperty(a) || !newAliases[key]) {
for (const a of [key, ...aliases[key]]) {
if (!Object.prototype.hasOwnProperty.call(newAliases, a) || !newAliases[key]) {
return true
}
}
Expand All @@ -170,7 +170,7 @@ module.exports = function validation (yargs, usage, y18n) {

Object.keys(argv).forEach((key) => {
if (specialKeys.indexOf(key) === -1 &&
options.choices.hasOwnProperty(key)) {
Object.prototype.hasOwnProperty.call(options.choices, key)) {
[].concat(argv[key]).forEach((value) => {
// TODO case-insensitive configurability
if (options.choices[key].indexOf(value) === -1 &&
Expand Down Expand Up @@ -252,7 +252,7 @@ module.exports = function validation (yargs, usage, y18n) {

function keyExists (argv, val) {
// convert string '1' to number 1
let num = Number(val)
const num = Number(val)
val = isNaN(num) ? val : num

if (typeof val === 'number') {
Expand Down Expand Up @@ -357,16 +357,16 @@ module.exports = function validation (yargs, usage, y18n) {
return self
}

let frozens = []
const frozens = []
self.freeze = function freeze () {
let frozen = {}
const frozen = {}
frozens.push(frozen)
frozen.implied = implied
frozen.checks = checks
frozen.conflicting = conflicting
}
self.unfreeze = function unfreeze () {
let frozen = frozens.pop()
const frozen = frozens.pop()
implied = frozen.implied
checks = frozen.checks
conflicting = frozen.conflicting
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -42,7 +42,7 @@
"hashish": "0.0.4",
"mocha": "^7.0.0",
"rimraf": "^3.0.0",
"standard": "^12.0.1",
"standard": "^14.0.0",
"which": "^2.0.0",
"yargs-test-extends": "^1.0.1"
},
Expand Down
22 changes: 11 additions & 11 deletions test/command.js
Expand Up @@ -154,13 +154,13 @@ describe('Command', () => {
.command('foo <bar> [awesome...]', 'my awesome command', noop, (argv2) => {
argv2.bar.should.eql('hello')
argv2.awesome.should.eql(['world', 'series'])
argv2['_'].should.eql(['foo', 'apple', 'banana'])
argv2._.should.eql(['foo', 'apple', 'banana'])
called = true
})
.parse()
argv.bar.should.eql('hello')
argv.awesome.should.eql(['world', 'series'])
argv['_'].should.eql(['foo', 'apple', 'banana'])
argv._.should.eql(['foo', 'apple', 'banana'])
called.should.equal(true)
})

Expand All @@ -171,7 +171,7 @@ describe('Command', () => {
.command('foo <bar> [awesome...]', 'my awesome command', noop, (argv2) => {
argv2.bar.should.eql('hello')
argv2.awesome.should.eql(['world', 'series'])
argv2['_'].should.eql(['foo'])
argv2._.should.eql(['foo'])
argv2['--'].should.eql(['apple', 'banana'])
called = true
})
Expand All @@ -181,7 +181,7 @@ describe('Command', () => {
.parse()
argv.bar.should.eql('hello')
argv.awesome.should.eql(['world', 'series'])
argv['_'].should.eql(['foo'])
argv._.should.eql(['foo'])
argv['--'].should.eql(['apple', 'banana'])
called.should.equal(true)
})
Expand Down Expand Up @@ -612,7 +612,7 @@ describe('Command', () => {
it('supports nested subcommands', () => {
const r = checkOutput(() => yargs('dream --help').wrap(null)
.commandDir('fixtures/cmddir')
.parse(), [ './command' ])
.parse(), ['./command'])
r.exit.should.equal(true)
r.errors.length.should.equal(0)
r.logs[0].split(/\n+/).should.deep.equal([
Expand Down Expand Up @@ -680,7 +680,7 @@ describe('Command', () => {
it('detects and ignores cyclic dir references', () => {
const r = checkOutput(() => yargs('cyclic --help').wrap(null)
.commandDir('fixtures/cmddir_cyclic')
.parse(), [ './command' ])
.parse(), ['./command'])
r.exit.should.equal(true)
r.errors.length.should.equal(0)
r.should.have.property('logs')
Expand Down Expand Up @@ -732,27 +732,27 @@ describe('Command', () => {
const helpCmd = checkOutput(() => yargs('help cmd')
.wrap(null)
.command(cmd)
.parse(), [ './command' ])
.parse(), ['./command'])

const cmdHelp = checkOutput(() => yargs('cmd help')
.wrap(null)
.command(cmd)
.parse(), [ './command' ])
.parse(), ['./command'])

const helpCmdSub = checkOutput(() => yargs('help cmd sub')
.wrap(null)
.command(cmd)
.parse(), [ './command' ])
.parse(), ['./command'])

const cmdHelpSub = checkOutput(() => yargs('cmd help sub')
.wrap(null)
.command(cmd)
.parse(), [ './command' ])
.parse(), ['./command'])

const cmdSubHelp = checkOutput(() => yargs('cmd sub help')
.wrap(null)
.command(cmd)
.parse(), [ './command' ])
.parse(), ['./command'])

const expectedCmd = [
'command cmd <sub>',
Expand Down
4 changes: 2 additions & 2 deletions test/completion.js
Expand Up @@ -565,7 +565,7 @@ describe('Completion', () => {
const r = checkUsage(() => {
try {
return yargs(['./completion', '--get-yargs-completions', '--'])
.option('foo', { 'describe': 'bar' })
.option('foo', { describe: 'bar' })
.completion()
.strict()
.argv
Expand All @@ -583,7 +583,7 @@ describe('Completion', () => {
const r = checkUsage(() => {
try {
return yargs(['./completion', '--get-yargs-completions', 'dream'])
.commandDir('./fixtures/cmddir', { 'recurse': true })
.commandDir('./fixtures/cmddir', { recurse: true })
.demand(1)
.strict()
.completion()
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/utils.js
Expand Up @@ -15,7 +15,7 @@ exports.checkOutput = function checkOutput (f, argv, cb) {

process.exit = () => { exit = true }
process.env = Hash.merge(process.env, { _: 'node' })
process.argv = argv || [ './usage' ]
process.argv = argv || ['./usage']

const errors = []
const logs = []
Expand Down
22 changes: 11 additions & 11 deletions test/integration.js
Expand Up @@ -16,15 +16,15 @@ describe('integration tests', () => {
})

it('should run as a shell script with arguments', (done) => {
testArgs('./bin.js', [ 'a', 'b', 'c' ], done)
testArgs('./bin.js', ['a', 'b', 'c'], done)
})

it('should run as a node script with no arguments', (done) => {
testArgs('node bin.js', [], done)
})

it('should run as a node script with arguments', (done) => {
testArgs('node bin.js', [ 'x', 'y', 'z' ], done)
testArgs('node bin.js', ['x', 'y', 'z'], done)
})

describe('path returned by "which"', () => {
Expand All @@ -40,14 +40,14 @@ describe('integration tests', () => {
which('node', (err, resolvedPath) => {
if (err) return done(err)
testArgs(`${resolvedPath.replace('Program Files (x86)', 'Progra~2')
.replace('Program Files', 'Progra~1')} bin.js`, [ 'q', 'r' ], done)
.replace('Program Files', 'Progra~1')} bin.js`, ['q', 'r'], done)
})
})
})

// see #177
it('allows --help to be completed without returning help message', (done) => {
testCmd('./bin.js', [ '--get-yargs-completions', '--h' ], (code, stdout) => {
testCmd('./bin.js', ['--get-yargs-completions', '--h'], (code, stdout) => {
if (code) {
done(new Error(`cmd exited with code ${code}`))
return
Expand All @@ -66,7 +66,7 @@ describe('integration tests', () => {
return this.skip()
}

testCmd('./issue-497.js', [ '--help' ], (code, stdout) => {
testCmd('./issue-497.js', ['--help'], (code, stdout) => {
if (code) {
done(new Error(`cmd exited with code ${code}`))
return
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('integration tests', () => {

describe('version #', () => {
it('defaults to appropriate version # when yargs is installed normally', (done) => {
testCmd('./normal-bin.js', [ '--version' ], (code, stdout) => {
testCmd('./normal-bin.js', ['--version'], (code, stdout) => {
if (code) {
return done(new Error(`cmd exited with code ${code}`))
}
Expand All @@ -136,7 +136,7 @@ describe('integration tests', () => {
})

it('defaults to appropriate version # when yargs is symlinked', (done) => {
testCmd('./symlink-bin.js', [ '--version' ], (code, stdout) => {
testCmd('./symlink-bin.js', ['--version'], (code, stdout) => {
if (code) {
return done(new Error(`cmd exited with code ${code}`))
}
Expand All @@ -149,7 +149,7 @@ describe('integration tests', () => {

describe('parser settings', () => {
it('reads parser config settings when yargs is installed normally', (done) => {
testCmd('./normal-bin.js', [ '--foo.bar' ], (code, stdout) => {
testCmd('./normal-bin.js', ['--foo.bar'], (code, stdout) => {
if (code) {
return done(new Error(`cmd exited with code ${code}`))
}
Expand All @@ -160,7 +160,7 @@ describe('integration tests', () => {
})

it('reads parser config settings when yargs is installed as a symlink', (done) => {
testCmd('./symlink-bin.js', [ '--foo.bar' ], (code, stdout) => {
testCmd('./symlink-bin.js', ['--foo.bar'], (code, stdout) => {
if (code) {
return done(new Error(`cmd exited with code ${code}`))
}
Expand All @@ -171,7 +171,7 @@ describe('integration tests', () => {
})

it('reads parser config settings when somebody obscures require.main', (done) => {
testCmd('./no-require-main.js', [ '--foo.bar' ], (code, stdout) => {
testCmd('./no-require-main.js', ['--foo.bar'], (code, stdout) => {
if (code) {
return done(new Error(`cmd exited with code ${code}`))
}
Expand All @@ -182,7 +182,7 @@ describe('integration tests', () => {
})

it('reads parser config settings when entry file has no extension', (done) => {
testCmd('./no-extension', [ '--foo.bar' ], (code, stdout) => {
testCmd('./no-extension', ['--foo.bar'], (code, stdout) => {
if (code) {
return done(new Error(`cmd exited with code ${code}`))
}
Expand Down

0 comments on commit 996329b

Please sign in to comment.