From b3ebca5dcbd87c2b28ee16f6a84a02704f4b8890 Mon Sep 17 00:00:00 2001 From: Edward Jones Date: Mon, 16 Mar 2020 21:59:10 -0300 Subject: [PATCH] Use istanbul babel plugin only in tests (#536) Prevents coverage instrumentation code from being in the final package. Fixes #535. --- .babelrc | 10 ++++++--- package-lock.json | 52 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/.babelrc b/.babelrc index efc403d6..9af382fd 100644 --- a/.babelrc +++ b/.babelrc @@ -9,7 +9,11 @@ } ] ], - "plugins": [ - "istanbul" - ] + "env": { + "test": { + "plugins": [ + "istanbul" + ] + } + } } diff --git a/package-lock.json b/package-lock.json index d42e252c..6a15b3bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3623,6 +3623,58 @@ } } }, + "cross-env": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-6.0.3.tgz", + "integrity": "sha512-+KqxF6LCvfhWvADcDPqo64yVIB31gv/jQulX2NGzKS/g3GEVz6/pt4wjHFtFWsHMddebWD/sDthJemzM4MaAag==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", + "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", diff --git a/package.json b/package.json index 46e246fc..36c52cbf 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "build": "babel lib --out-dir dist", "prepare": "npm run build", "lint": "eslint . --ignore-path .gitignore", - "coverage": "nyc --require @babel/register mocha -- 'test/*.test.js'", + "coverage": "cross-env NODE_ENV=test nyc --require @babel/register mocha -- 'test/*.test.js'", "report": "nyc report --reporter=text-lcov | coveralls", "test": "npm run lint && npm run coverage" }, @@ -57,6 +57,7 @@ "babel-plugin-istanbul": "^5.2.0", "chai": "^4.2.0", "coveralls": "^3.0.9", + "cross-env": "^6.0.3", "eslint": "^6.7.2", "eslint-config-airbnb-base": "^14.0.0", "eslint-plugin-import": "^2.19.1",