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

Bump ini from 1.3.5 to 1.3.7 #153

Closed
wants to merge 115 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
56bc236
2.1.0
leo Oct 2, 2016
83dcb56
chore(package): update execa to version 0.5.0 (#34)
greenkeeperio-bot Oct 5, 2016
ad43856
Tiny improvements
leo Oct 8, 2016
19f1544
Update xo to version 0.17.0 🚀 (#36)
greenkeeperio-bot Oct 15, 2016
b8ea96c
add default values to `--help` output
TooTallNate Nov 2, 2016
53dc939
fix `xo` lint
TooTallNate Nov 2, 2016
798469c
don't set a default value for `--version`
TooTallNate Nov 3, 2016
0c8a004
use enabled/disabled for boolean default values
TooTallNate Nov 3, 2016
74c4093
Add default values to `--help` output (#39)
leo Nov 14, 2016
94957ff
chore(package): update ava to version 0.17.0 (#44)
greenkeeperio-bot Nov 17, 2016
00782fe
Propogate minimist options (#47)
codyzu Dec 2, 2016
3a4b648
2.2.0
leo Dec 8, 2016
fed1f8a
Improved badges and intro
leo Dec 8, 2016
f962060
proxy sub-commands' exit codes and signals (#48)
TooTallNate Dec 13, 2016
a4f1d34
2.2.1
leo Dec 13, 2016
b07cf9d
Command line indicator removed
leo Jan 7, 2017
1dc583e
Better wording for installation
leo Jan 7, 2017
94e2f21
Allow int arg to be 0 (#49)
pablopunk Jan 8, 2017
79fdf4d
Added author section
leo Jan 8, 2017
06e50f1
chore(package): update execa to version 0.6.0 (#50)
greenkeeperio-bot Jan 9, 2017
bd4d2bd
2.2.2
leo Jan 12, 2017
4033f5f
Use JSON for Travis CI config file
leo Jan 12, 2017
4ac8d90
Goodbye transpilation workflow
leo Jan 12, 2017
9d38330
Made package keywords much more concise
leo Jan 12, 2017
8c0c37c
No need to run a development script anymore
leo Jan 12, 2017
1898df0
The output directory doesn't need to be ignored
leo Jan 12, 2017
c7b1cc8
Use regular require statements for loading packages
leo Jan 12, 2017
5e6e5bd
Export module using already working syntax
leo Jan 12, 2017
b1b9be1
Bumped package to latest version
leo Jan 12, 2017
f8a1ed4
2.2.3
leo Jan 12, 2017
64c2213
Node.js v4, v5 support (#51)
TooTallNate Jan 19, 2017
aea0181
2.2.4
leo Jan 19, 2017
d2ea64a
chore(package): update ava to version 0.18.0 (#53)
greenkeeperio-bot Feb 3, 2017
a97d055
Transform duplicated short flag to upper case (#55)
ntwcklng Feb 5, 2017
a5a8308
make it work (#56)
ntwcklng Feb 10, 2017
b56052d
Pinned dependencies
leo Feb 10, 2017
05fb7f9
No need to tell greenkeeper about the mails anymore
leo Feb 10, 2017
b0c76b1
Make license legally correct
leo Feb 10, 2017
f0aa561
2.3.0
leo Feb 10, 2017
bdbb319
Bump node version in engines, remove loud-rejection (#61)
rtsao Feb 14, 2017
ce9a185
chore(package): update ava to version 0.18.2 (#62)
greenkeeper[bot] Feb 21, 2017
9af064a
Lowercased text files
leo Feb 21, 2017
f3a64cd
Change output colors in config (#65)
ntwcklng Mar 5, 2017
44d9b6a
Add .example + .examples sub command (#60) (#63)
ntwcklng Mar 15, 2017
3682ac1
Test on Node LTS as well
leo Mar 25, 2017
b5bdbe4
Added `.editorconfig` file
leo Mar 25, 2017
9fd1ef3
Use `prettier`
leo Mar 25, 2017
0821926
Added missing dependencies
leo Mar 25, 2017
a3ff062
Script running for each commit added
leo Mar 25, 2017
a7e01b8
Prettified everything
leo Mar 25, 2017
f0b93b9
Only lint on each commit, don't run unit tests
leo Mar 25, 2017
66461e8
2.4.0
leo Mar 25, 2017
401789c
Fix bug in option value with booleans (#72)
ntwcklng Mar 29, 2017
1348e6a
Added @ntwcklng as author
leo Mar 29, 2017
7f23720
2.4.1
leo Mar 29, 2017
d740803
Fix .options defaultValue (#75)
ntwcklng Apr 10, 2017
3601580
remove undefined default value (#78)
ntwcklng Apr 11, 2017
995f514
2.4.2
leo Apr 11, 2017
fc2d08e
Bumped dependencies to the latest version
leo Apr 11, 2017
cf870a2
Fixed linting
leo Apr 11, 2017
6189bd0
Display help when subcommand is unknown (#76)
ntwcklng Apr 11, 2017
fa20d63
2.5.0
leo Apr 11, 2017
d3691cd
remove unknown subcommand suggestion, add unknown option suggestion (…
ntwcklng Apr 13, 2017
3b7d9cc
Only show help if there's no option suggestion
leo Apr 13, 2017
e1d261e
Tell users about the new suggestion feature
leo Apr 13, 2017
e64421b
Removed unnecessary line break
leo Apr 13, 2017
438ce93
2.6.0
leo Apr 13, 2017
fcddca4
Fix option suggestion when running a subcommand (#87)
ntwcklng Apr 25, 2017
2646df4
2.6.1
leo Apr 25, 2017
f0c8d8a
Move away from exporting a class and split methods into separate file…
ntwcklng Apr 28, 2017
e870634
Convert the option value to an array if the defaultValue is an array …
ntwcklng May 8, 2017
ef2079f
Bumped dependencies to the latest version
leo May 9, 2017
890d5d0
3.0.0
leo May 9, 2017
1d10d95
Fixes Node.js v4 LTS (#92)
TooTallNate May 12, 2017
5f35db3
Indicate that we're now supporting Node 4
leo May 12, 2017
792cbe8
3.0.1
leo May 12, 2017
f2744b3
Pass in parent module from `index.js` (#96)
TooTallNate May 24, 2017
97dc4f0
3.0.2
leo May 24, 2017
15314dc
Made package robust against `pkginfo` errors (#97)
dotob Jul 16, 2017
8131d05
Lockfile added
leo Jul 16, 2017
626618c
Bumped dependencies to the latest version
leo Jul 16, 2017
21ff9fb
3.0.3
leo Jul 16, 2017
6198c60
Fixed linting
leo Jul 16, 2017
dffdb84
3.0.4
leo Jul 16, 2017
5e892d0
Replace minimist with mri (#100)
ntwcklng Jul 27, 2017
97805c1
Bumped dependencies to the latest version (#104)
ntwcklng Aug 29, 2017
17c1b6b
Fix subcommand on windows (#105)
ntwcklng Oct 9, 2017
1a91a8d
3.0.5
ntwcklng Oct 9, 2017
fa43fbb
Require pkginfo only if needed (#106)
chabou Oct 11, 2017
5b9d699
3.0.6
leo Oct 11, 2017
ac0e454
allow both mri and minimist options (#109)
ntwcklng Oct 11, 2017
42fa0dc
Add AppVeyor (#107)
ntwcklng Oct 11, 2017
470c888
3.0.7
ntwcklng Oct 11, 2017
38951fb
use master branch for appveyor
ntwcklng Oct 15, 2017
3168f06
Allow setting option init without default value (#114)
aapokiiso Nov 28, 2017
f19c7e3
3.0.8
ntwcklng Nov 28, 2017
19fecc4
fix(defaults): Process help and version defaults better (#116)
markhalliwell Apr 3, 2018
d28831b
Change "string-similarity" to "leven" (#121)
icebob Apr 9, 2018
acb268f
no semicolons
ntwcklng Apr 9, 2018
73ac1f7
update deps
ntwcklng Apr 9, 2018
a8ce204
run prettier
ntwcklng Apr 9, 2018
da38306
4.0.0
ntwcklng Apr 9, 2018
4a474a0
Compact layout (#124)
oskarrough May 23, 2018
8c3a6df
chore: cache node_modules (#126)
DanielRuf Jun 12, 2018
3fb435b
update deps and fix lint errors
ntwcklng Jun 14, 2018
3442d37
remove node 4 support
ntwcklng Jun 14, 2018
d29416b
node support in readme
ntwcklng Jun 15, 2018
490e18c
5.0.0
ntwcklng Jun 15, 2018
8b2f0ac
Update exports (#122)
keineausweise Aug 18, 2018
f48581d
update deps
ntwcklng Mar 5, 2019
c7a0882
5.0.1
ntwcklng Mar 5, 2019
4bc4b53
Update readme.md usage example use commonjs instead of es6 module imp…
yuler Apr 30, 2019
018eee7
Rename function `firstBig` => `capitalize` (#140)
yuler Apr 30, 2019
51430ea
fix #146 (#147)
mspiess Oct 19, 2020
a36a867
Bump ini from 1.3.5 to 1.3.7
dependabot[bot] Dec 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# More details: editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{json,yml}]
indent_style = space
indent_size = 2
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# build output
dist

# dependencies
node_modules

Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact = true
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: node_js
sudo: false
node_js: node
git:
depth: 1
node_js:
- "6"
- "8"
- "node"
cache:
directories:
- node_modules
18 changes: 18 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
branches:
only:
- master

environment:
matrix:
- nodejs_version: "6"

install:
- ps: Install-Product node $env:nodejs_version
- npm install

test_script:
- node --version
- npm --version
- npm run test

build: off
14 changes: 0 additions & 14 deletions gulpfile.babel.js

This file was deleted.

22 changes: 22 additions & 0 deletions lib/command.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

module.exports = function(usage, description, init, aliases) {
if (Array.isArray(init)) {
aliases = init
init = undefined
}

if (aliases && Array.isArray(aliases)) {
usage = [].concat([usage], aliases)
}

// Register command to global scope
this.details.commands.push({
usage,
description,
init: typeof init === 'function' ? init : false
})

// Allow chaining of .command()
return this
}
13 changes: 13 additions & 0 deletions lib/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

module.exports = function(usage, description) {
if (typeof usage !== 'string' || typeof description !== 'string') {
throw new TypeError(
'Usage for adding an Example: args.example("usage", "description")'
)
}

this.details.examples.push({ usage, description })

return this
}
15 changes: 15 additions & 0 deletions lib/examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

module.exports = function(list) {
if (list.constructor !== Array) {
throw new Error('Item passed to .examples is not an array')
}

for (const item of list) {
const usage = item.usage || false
const description = item.description || false
this.example(usage, description)
}

return this
}
75 changes: 75 additions & 0 deletions lib/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict'

module.exports = function() {
const name = this.config.name || this.binary.replace('-', ' ')
const capitalize = word => word.charAt(0).toUpperCase() + word.substr(1)

const parts = []

const groups = {
commands: true,
options: true,
examples: true
}

for (const group in groups) {
if (this.details[group].length > 0) {
continue
}

groups[group] = false
}

const optionHandle = groups.options ? '[options] ' : ''
const cmdHandle = groups.commands ? '[command]' : ''
const value =
typeof this.config.value === 'string' ? ' ' + this.config.value : ''

parts.push([
` Usage: ${this.printMainColor(name)} ${this.printSubColor(
optionHandle + cmdHandle + value
)}`,
''
])

for (const group in groups) {
if (!groups[group]) {
continue
}

parts.push(['', capitalize(group) + ':', ''])

if (group === 'examples') {
parts.push(this.generateExamples())
} else {
parts.push(this.generateDetails(group))
}

parts.push(['', ''])
}

let output = ''

// And finally, merge and output them
for (const part of parts) {
output += part.join('\n ')
}

if (!groups.commands && !groups.options) {
output = 'No sub commands or options available'
}

const { usageFilter } = this.config

// If filter is available, pass usage information through
if (typeof usageFilter === 'function') {
output = usageFilter(output) || output
}

console.log(output)

if (this.config.exit && this.config.exit.help) {
// eslint-disable-next-line unicorn/no-process-exit
process.exit()
}
}
59 changes: 59 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict'

const chalk = require('chalk')
const utils = require('./utils')

const publicMethods = {
option: require('./option'),
options: require('./options'),
command: require('./command'),
parse: require('./parse'),
example: require('./example'),
examples: require('./examples'),
showHelp: require('./help'),
showVersion: require('./version')
}

function Args() {
this.details = {
options: [],
commands: [],
examples: []
}

// Configuration defaults
this.config = {
exit: { help: true, version: true },
help: true,
version: true,
usageFilter: null,
value: null,
name: null,
mainColor: 'yellow',
subColor: 'dim'
}

this.printMainColor = chalk
this.printSubColor = chalk
}

// Assign internal helpers
for (const util in utils) {
if (!{}.hasOwnProperty.call(utils, util)) {
continue
}

Args.prototype[util] = utils[util]
}

// Assign public methods
for (const method in publicMethods) {
if (!{}.hasOwnProperty.call(publicMethods, method)) {
continue
}

Args.prototype[method] = publicMethods[method]
}

module.exports = new Args()
module.exports.Args = Args;
66 changes: 66 additions & 0 deletions lib/option.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict'

module.exports = function(name, description, defaultValue, init) {
let usage = []

const assignShort = (name, options, short) => {
if (options.find(flagName => flagName.usage[0] === short)) {
short = name.charAt(0).toUpperCase()
}

return [short, name]
}

// If name is an array, pick the values
// Otherwise just use the whole thing
switch (name.constructor) {
case String:
usage = assignShort(name, this.details.options, name.charAt(0))
break
case Array:
usage = usage.concat(name)
break
default:
throw new Error('Invalid name for option')
}

// Throw error if short option is too long
if (usage.length > 0 && usage[0].length > 1) {
throw new Error('Short version of option is longer than 1 char')
}

const optionDetails = {
defaultValue,
usage,
description
}

let defaultIsWrong

switch (defaultValue) {
case false:
defaultIsWrong = true
break
case null:
defaultIsWrong = true
break
case undefined:
defaultIsWrong = true
break
default:
defaultIsWrong = false
}

if (typeof init === 'function') {
optionDetails.init = init
} else if (!defaultIsWrong) {
// Set initializer depending on type of default value
optionDetails.init = this.handleType(defaultValue)[1]
}

// Register option to global scope
this.details.options.push(optionDetails)

// Allow chaining of .option()
return this
}
16 changes: 16 additions & 0 deletions lib/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

module.exports = function(list) {
if (list.constructor !== Array) {
throw new Error('Item passed to .options is not an array')
}

for (const item of list) {
const preset = item.defaultValue
const init = item.init || false

this.option(item.name, item.description, preset, init)
}

return this
}
Loading