Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
fix: gracefully degrade with no nock
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jun 1, 2018
1 parent 896cb3f commit f673db8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/nock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ export function nock(host?: string, options?: nock.Callback | nock.Options, cb?:
}
if (cb === undefined) throw new Error('callback is undefined')

const nock: typeof Nock = require('nock')
let nock: typeof Nock
try {
nock = require('nock')
} catch {
return {
run() {
require('nock')
}
}
}
const intercepter = nock(host, options)
return {
async run(ctx: {nock: number}) {
Expand Down

0 comments on commit f673db8

Please sign in to comment.