Skip to content

Commit 83df762

Browse files
committed
chore(deps): update dependencies, switch linting
Moved testing to use t.testdir so we don't need mkdirp or rimraf
1 parent dec763a commit 83df762

File tree

7 files changed

+1632
-2248
lines changed

7 files changed

+1632
-2248
lines changed

.eslintrc.json

Lines changed: 0 additions & 207 deletions
This file was deleted.

check-response.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,35 @@ const errors = require('./errors.js')
44
const { Response } = require('minipass-fetch')
55
const defaultOpts = require('./default-opts.js')
66

7-
const checkResponse = async ({ method, uri, res, registry, startTime, auth, opts }) => {
8-
opts = { ...defaultOpts, ...opts }
9-
if (res.headers.has('npm-notice') && !res.headers.has('x-local-cache'))
10-
opts.log.notice('', res.headers.get('npm-notice'))
7+
const checkResponse =
8+
async ({ method, uri, res, registry, startTime, auth, opts }) => {
9+
opts = { ...defaultOpts, ...opts }
10+
if (res.headers.has('npm-notice') && !res.headers.has('x-local-cache'))
11+
opts.log.notice('', res.headers.get('npm-notice'))
1112

12-
if (res.status >= 400) {
13-
logRequest(method, res, startTime, opts)
14-
if (auth && auth.scopeAuthKey && !auth.token && !auth.auth) {
13+
if (res.status >= 400) {
14+
logRequest(method, res, startTime, opts)
15+
if (auth && auth.scopeAuthKey && !auth.token && !auth.auth) {
1516
// we didn't have auth for THIS request, but we do have auth for
1617
// requests to the registry indicated by the spec's scope value.
1718
// Warn the user.
18-
opts.log.warn('registry', `No auth for URI, but auth present for scoped registry.
19+
opts.log.warn('registry', `No auth for URI, but auth present for scoped registry.
1920
2021
URI: ${uri}
2122
Scoped Registry Key: ${auth.scopeAuthKey}
2223
2324
More info here: https://github.com/npm/cli/wiki/No-auth-for-URI,-but-auth-present-for-scoped-registry`)
25+
}
26+
return checkErrors(method, res, startTime, opts)
27+
} else {
28+
res.body.on('end', () => logRequest(method, res, startTime, opts))
29+
if (opts.ignoreBody) {
30+
res.body.resume()
31+
return new Response(null, res)
32+
}
33+
return res
2434
}
25-
return checkErrors(method, res, startTime, opts)
26-
} else {
27-
res.body.on('end', () => logRequest(method, res, startTime, opts))
28-
if (opts.ignoreBody) {
29-
res.body.resume()
30-
return new Response(null, res)
31-
}
32-
return res
3335
}
34-
}
3536
module.exports = checkResponse
3637

3738
function logRequest (method, res, startTime, opts) {
@@ -85,7 +86,8 @@ function checkErrors (method, res, startTime, opts) {
8586
)
8687
}
8788
} else if (res.status === 401 && body != null && /one-time pass/.test(body.toString('utf8'))) {
88-
// Heuristic for malformed OTP responses that don't include the www-authenticate header.
89+
// Heuristic for malformed OTP responses that don't include the
90+
// www-authenticate header.
8991
throw new errors.HttpErrorAuthOTP(
9092
method, res, parsed, opts.spec
9193
)

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ function fetchJSON (uri, opts) {
160160
}
161161

162162
module.exports.json.stream = fetchJSONStream
163-
function fetchJSONStream (uri, jsonPath, /* istanbul ignore next */ opts_ = {}) {
163+
function fetchJSONStream (uri, jsonPath,
164+
/* istanbul ignore next */ opts_ = {}) {
164165
const opts = { ...defaultOpts, ...opts_ }
165166
const parser = JSONStream.parse(jsonPath, opts.mapJSON)
166167
regFetch(uri, opts).then(res =>

0 commit comments

Comments
 (0)