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

Commit

Permalink
fix: move chai to non-required
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 21, 2018
1 parent e773199 commit 692f325
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/jdxcode/fancy-mocha/issues",
"dependencies": {
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"lodash": "^4.17.4",
"stdout-stderr": "^0.1.4"
},
Expand All @@ -18,6 +16,8 @@
"@types/lodash": "^4.14.93",
"@types/mocha": "^2.2.46",
"@types/node": "^9.3.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^4.16.0",
"eslint-config-dxcli": "^1.1.4",
"husky": "^0.14.3",
Expand Down
18 changes: 14 additions & 4 deletions src/chai.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
chai.use(chaiAsPromised)
// tslint:disable no-unused

export const {expect} = chai
const tryRequire = (module: string) => {
try {
return require(module)
} catch (_) {
}
}

const chai: Chai.ChaiStatic = tryRequire('chai')

const chaiAsPromised = tryRequire('chai-as-promised')
if (chai && chaiAsPromised) chai.use(chaiAsPromised)

export const expect = chai && chai.expect

0 comments on commit 692f325

Please sign in to comment.