Skip to content

Commit

Permalink
feat: bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Feb 12, 2024
1 parent 21ce6ad commit 3e066e9
Show file tree
Hide file tree
Showing 7 changed files with 1,934 additions and 677 deletions.
4 changes: 1 addition & 3 deletions .eslintrc
Expand Up @@ -2,7 +2,5 @@
"extends": [
"oclif",
"oclif-typescript"
],
"rules": {
}
]
}
7 changes: 7 additions & 0 deletions .mocharc.json
@@ -0,0 +1,7 @@
{
"require": ["ts-node/register"],
"watch-extensions": ["ts"],
"recursive": true,
"reporter": "spec",
"timeout": 60000
}
22 changes: 10 additions & 12 deletions package.json
Expand Up @@ -7,22 +7,20 @@
"dependencies": {},
"devDependencies": {
"@types/chai": "^4.3.11",
"@types/mocha": "^8.0.0",
"@types/mocha": "^10.0.0",
"@types/nock": "^11.1.0",
"@types/node": "^14.18.63",
"chai": "^4.4.1",
"concurrently": "^6.5.1",
"eslint": "^7.3.1",
"eslint-config-anycli": "^1.3.2",
"eslint-config-oclif": "^3.1.0",
"eslint-config-oclif-typescript": "^0.2.0",
"fancy-test": "^1.0.4",
"eslint": "^8",
"eslint-config-oclif": "^5",
"eslint-config-oclif-typescript": "^3",
"fancy-test": "^3",
"http-call": "^5.1.0",
"mocha": "^5.1.0",
"mocha": "^10",
"nock": "^13.5.1",
"sinon": "^9.0.2",
"ts-node": "^9.0.0",
"typescript": "4.6.3"
"sinon": "^17",
"ts-node": "^10",
"typescript": "^5"
},
"engines": {
"node": ">=12.0.0"
Expand All @@ -41,7 +39,7 @@
"build": "rm -rf lib && tsc",
"lint": "eslint . --ext .ts --config .eslintrc",
"prepublishOnly": "yarn run build",
"pretest": "yarn build --noEmit && tsc -p test --noEmit",
"pretest": "yarn build && tsc -p test --noEmit",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
"posttest": "yarn lint"
},
Expand Down
11 changes: 7 additions & 4 deletions src/index.ts
@@ -1,26 +1,29 @@
import * as Nock from 'nock'

export import NockScope = Nock.Scope
export type Callback = (nock: NockScope) => any
export type Callback = (nock: NockScope) => unknown

export default function nock(host?: string, options?: Callback | Nock.Options, cb?: Callback) {
if (host === undefined) throw new Error('host is undefined')
if (typeof options === 'function') {
cb = options
options = {}
}

if (cb === undefined) throw new Error('callback is undefined')

// eslint-disable-next-line unicorn/prefer-module
const nock: typeof Nock = require('nock')
const intercepter = nock(host, options)
const interceptor = nock(host, options)
return {
async run(ctx: {nock: number}) {
ctx.nock = ctx.nock || 0
await cb!(intercepter)
await cb!(interceptor)
ctx.nock++
},
// eslint-disable-next-line perfectionist/sort-objects
finally(ctx: {error?: Error; nock: number}) {
if (!ctx.error) intercepter.done()
if (!ctx.error) interceptor.done()
ctx.nock--
if (ctx.nock === 0) nock.cleanAll()
},
Expand Down
3 changes: 2 additions & 1 deletion test/index.test.ts
@@ -1,4 +1,5 @@
import {expect, fancy as base} from 'fancy-test'
/* eslint-disable import/no-named-as-default */
import {fancy as base, expect} from 'fancy-test'
import HTTP from 'http-call'

import nock, {NockScope} from '../src'
Expand Down
6 changes: 0 additions & 6 deletions test/mocha.opts

This file was deleted.

0 comments on commit 3e066e9

Please sign in to comment.