Skip to content

Commit

Permalink
chore: Upgrade dependencies
Browse files Browse the repository at this point in the history
* Minimum Node.js is 12 (commander)
* Adapt sources for the new commander and lint requirements
* Exchange package lock of npm for pnpm.

BREAKING CHANGE:
  Node.js has to be upgraded to 12 or newer version.
  • Loading branch information
prantlf committed Dec 12, 2021
1 parent 35b46a5 commit 5dbbff7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions bin/nettime
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ if (!url) {
commander.help()
}

const timeUnit = commander.timeUnit || 'ms'
const options = commander.opts()
const timeUnit = options.timeUnit || 'ms'
if (['ms', 's+ns'].indexOf(timeUnit) < 0) {
console.error(`Invalid time unit: "${timeUnit}". Valid values are "ms", and "s+ns".`)
process.exit(1)
Expand All @@ -67,14 +68,14 @@ const formatters = {
`\nResponse: HTTP/${httpVersion} ${statusCode} ${statusMessage}`
}

const format = commander.format || 'text'
const format = options.format || 'text'
const formatter = formatters[format]
if (!formatter) {
console.error(`Invalid format: "${format}". Valid formats are "text", "json" and "raw".`)
process.exit(1)
}

const headers = commander.header.reduce((result, header) => {
const headers = options.header.reduce((result, header) => {
const colon = header.indexOf(':')
if (colon > 0) {
const name = header
Expand All @@ -89,7 +90,7 @@ const headers = commander.header.reduce((result, header) => {
return result
}, {})

let credentials = commander.user
let credentials = options.user
if (credentials) {
const colon = credentials.indexOf(':')
let username, password
Expand All @@ -106,8 +107,8 @@ if (credentials) {
const {
connectTimeout: timeout, data, head, include: includeHeaders, insecure,
output: outputFile, request, requestCount, requestDelay, averageTimings
} = commander
const httpVersion = commander.http2 ? '2.0' : commander['http1.0'] ? '1.0' : '1.1'
} = options
const httpVersion = options.http2 ? '2.0' : options['http1.0'] ? '1.0' : '1.1'
const method = request || (head ? 'HEAD' : data ? 'POST' : 'GET')
const failOnOutputFileError = false
const rejectUnauthorized = !insecure
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"engines": {
"node": ">=8"
"node": ">=12"
},
"main": "./lib/nettime.js",
"bin": {
Expand All @@ -44,7 +44,7 @@
"check-coverage": false
},
"dependencies": {
"commander": "3.0.2",
"commander": "8.3.0",
"readline-sync": "1.4.10",
"sprintf-js": "1.1.2"
},
Expand Down
9 changes: 5 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5dbbff7

Please sign in to comment.