diff --git a/.pnp.cjs b/.pnp.cjs index 87883ffe2b..ed881cf8b6 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -2906,7 +2906,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["crypto-browserify", "npm:3.12.0"],\ ["crypto-js", "npm:4.1.1"],\ ["dirty-chai", "virtual:12a596dc9572e25ce715d3736dc74b317c5ca5cfb3b4f67864b1e76b3a401006f84d381aaf975bb5b4da9cafac5125e6869fc78d5202f4c95780c81479112f32#npm:2.0.1"],\ - ["dotenv", "npm:8.6.0"],\ + ["dotenv-safe", "npm:8.2.0"],\ ["eslint", "npm:7.32.0"],\ ["eslint-config-airbnb-base", "virtual:12a596dc9572e25ce715d3736dc74b317c5ca5cfb3b4f67864b1e76b3a401006f84d381aaf975bb5b4da9cafac5125e6869fc78d5202f4c95780c81479112f32#npm:14.2.1"],\ ["eslint-plugin-import", "virtual:12a596dc9572e25ce715d3736dc74b317c5ca5cfb3b4f67864b1e76b3a401006f84d381aaf975bb5b4da9cafac5125e6869fc78d5202f4c95780c81479112f32#npm:2.25.3"],\ @@ -8187,7 +8187,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["chance", "npm:1.1.8"],\ ["crypto-browserify", "npm:3.12.0"],\ ["dirty-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:2.0.1"],\ - ["dotenv", "npm:8.6.0"],\ + ["dotenv-safe", "npm:8.2.0"],\ ["eslint", "npm:7.32.0"],\ ["eslint-config-airbnb-base", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:14.2.1"],\ ["eslint-config-airbnb-typescript", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:17.0.0"],\ diff --git a/packages/js-dash-sdk/karma/options.js b/packages/js-dash-sdk/karma/options.js index 81839aebdb..7472ceea15 100644 --- a/packages/js-dash-sdk/karma/options.js +++ b/packages/js-dash-sdk/karma/options.js @@ -1,6 +1,6 @@ /* eslint-disable import/no-extraneous-dependencies */ const webpack = require('webpack'); -const dotenvResult = require('dotenv').config(); +const dotenvSafe = require('dotenv-safe'); const karmaMocha = require('karma-mocha'); const karmaMochaReporter = require('karma-mocha-reporter'); @@ -9,6 +9,15 @@ const karmaChromeLauncher = require('karma-chrome-launcher'); const karmaWebpack = require('karma-webpack'); const webpackBaseConfig = require('../webpack.base.config'); +let env = {}; +if (process.env.LOAD_ENV) { + const dotenvResult = dotenvSafe.config(); + if (dotenvResult.error) { + throw dotenvResult.error; + } + env = dotenvResult.parsed; +} + module.exports = { frameworks: ['mocha', 'chai', 'webpack'], webpack: { @@ -17,7 +26,7 @@ module.exports = { plugins: [ ...webpackBaseConfig.plugins, new webpack.EnvironmentPlugin( - dotenvResult.parsed, + env, ), ], }, diff --git a/packages/js-dash-sdk/package.json b/packages/js-dash-sdk/package.json index d4de4b848e..75cb3c4350 100644 --- a/packages/js-dash-sdk/package.json +++ b/packages/js-dash-sdk/package.json @@ -15,9 +15,9 @@ "lint:fix": "eslint . --fix", "test": "yarn run test:types && yarn run test:unit && yarn run test:browsers", "test:browsers": "karma start ./karma/karma.conf.js --single-run", - "test:browsers:functional": "karma start ./karma/karma.functional.conf.js --single-run", + "test:browsers:functional": "LOAD_ENV=true karma start ./karma/karma.functional.conf.js --single-run", "test:unit": "ts-mocha -p tsconfig.mocha.json src/**/*.spec.ts", - "test:functional": "yarn run build && mocha --recursive tests/functional/**/*.js", + "test:functional": "yarn run build:ts && LOAD_ENV=true mocha --recursive tests/functional/**/*.js", "test:types": "yarn pnpify tsd", "prepublishOnly": "yarn run build", "prepare": "yarn run build" @@ -72,7 +72,7 @@ "chance": "^1.1.6", "crypto-browserify": "^3.12.0", "dirty-chai": "^2.0.1", - "dotenv": "^8.6.0", + "dotenv-safe": "^8.2.0", "eslint": "^7.32.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-typescript": "^17.0.0", diff --git a/packages/js-dash-sdk/src/test/bootstrap.js b/packages/js-dash-sdk/src/test/bootstrap.js index efd5e0cc03..29b19d5a29 100644 --- a/packages/js-dash-sdk/src/test/bootstrap.js +++ b/packages/js-dash-sdk/src/test/bootstrap.js @@ -1,15 +1,16 @@ -const dotenv = require('dotenv'); const path = require('path'); - +const dotenvSafe = require('dotenv-safe'); const sinon = require('sinon'); const sinonChai = require('sinon-chai'); const { use } = require('chai'); const dirtyChai = require('dirty-chai'); const chaiAsPromised = require('chai-as-promised'); -dotenv.config({ - path: path.resolve(__dirname, '..', '..', '.env'), -}); +if (process.env.LOAD_ENV === 'true') { + dotenvSafe.config({ + path: path.resolve(__dirname, '..', '..', '.env'), + }); +} use(dirtyChai); use(sinonChai); diff --git a/packages/wallet-lib/karma/options.js b/packages/wallet-lib/karma/options.js index 7e1bea6869..e4587e2c69 100644 --- a/packages/wallet-lib/karma/options.js +++ b/packages/wallet-lib/karma/options.js @@ -1,6 +1,6 @@ /* eslint-disable import/no-extraneous-dependencies */ const webpack = require('webpack'); -const dotenvResult = require('dotenv').config(); +const dotenvSafe = require('dotenv-safe'); const karmaMocha = require('karma-mocha'); const karmaMochaReporter = require('karma-mocha-reporter'); @@ -11,6 +11,15 @@ const karmaWebpack = require('karma-webpack'); const webpackConfig = require('../webpack.config'); +let env = {}; +if (process.env.LOAD_ENV) { + const dotenvResult = dotenvSafe.config(); + if (dotenvResult.error) { + throw dotenvResult.error; + } + env = dotenvResult.parsed; +} + module.exports = { client: { mocha: { @@ -24,7 +33,7 @@ module.exports = { plugins: [ ...webpackConfig.plugins, new webpack.EnvironmentPlugin( - dotenvResult.parsed, + env, ), ], resolve: webpackConfig.resolve, diff --git a/packages/wallet-lib/package.json b/packages/wallet-lib/package.json index 5b03a719f7..2719799d11 100644 --- a/packages/wallet-lib/package.json +++ b/packages/wallet-lib/package.json @@ -10,10 +10,10 @@ "lint": "eslint .", "lint:fix": "eslint . --fix", "test:unit": "nyc yarn mocha 'src/**/*.spec.js'", - "test:functional": "nyc yarn run mocha 'tests/functional/*.js'", + "test:functional": "LOAD_ENV=true nyc yarn run mocha 'tests/functional/*.js'", "test:integration": "nyc yarn run mocha 'tests/integration/**/*.spec.js'", "test:browsers": "karma start ./karma/karma.conf.js --single-run", - "test:browsers:functional": "karma start ./karma/karma.functional.conf.js --single-run", + "test:browsers:functional": "LOAD_ENV=true karma start ./karma/karma.functional.conf.js --single-run", "test:types": "yarn pnpify tsd", "test": "yarn run test:types && yarn run test:unit && yarn run test:integration && yarn run test:browsers", "prepublishOnly": "yarn run build:web" @@ -66,7 +66,7 @@ "chai-as-promised": "^7.1.1", "crypto-browserify": "^3.12.0", "dirty-chai": "^2.0.1", - "dotenv": "^8.6.0", + "dotenv-safe": "^8.2.0", "eslint": "^7.32.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-plugin-import": "^2.24.2", diff --git a/packages/wallet-lib/src/test/bootstrap.js b/packages/wallet-lib/src/test/bootstrap.js index 2e75d57042..48a5de18ef 100644 --- a/packages/wallet-lib/src/test/bootstrap.js +++ b/packages/wallet-lib/src/test/bootstrap.js @@ -1,7 +1,7 @@ const { use } = require('chai'); const { expect } = require('chai'); +const dotenvSafe = require('dotenv-safe'); const path = require('path'); -const dotenv = require('dotenv'); const sinon = require('sinon'); const sinonChai = require('sinon-chai'); const dirtyChai = require('dirty-chai'); @@ -11,9 +11,11 @@ use(sinonChai); use(dirtyChai); use(chaiAsPromised); -dotenv.config({ - path: path.resolve(__dirname, '..', '..', '.env'), -}); +if (process.env.LOAD_ENV === 'true') { + dotenvSafe.config({ + path: path.resolve(__dirname, '..', '..', '.env'), + }); +} beforeEach(function beforeEach() { if (!this.sinon) { diff --git a/yarn.lock b/yarn.lock index 2aa910ab39..4991f30de9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1874,7 +1874,7 @@ __metadata: crypto-browserify: ^3.12.0 crypto-js: ^4.0.0 dirty-chai: ^2.0.1 - dotenv: ^8.6.0 + dotenv-safe: ^8.2.0 eslint: ^7.32.0 eslint-config-airbnb-base: ^14.2.1 eslint-plugin-import: ^2.24.2 @@ -6117,7 +6117,7 @@ __metadata: chance: ^1.1.6 crypto-browserify: ^3.12.0 dirty-chai: ^2.0.1 - dotenv: ^8.6.0 + dotenv-safe: ^8.2.0 eslint: ^7.32.0 eslint-config-airbnb-base: ^14.2.1 eslint-config-airbnb-typescript: ^17.0.0