diff --git a/.coveralls.yml.example b/.coveralls.yml.example new file mode 100644 index 0000000..8ab631e --- /dev/null +++ b/.coveralls.yml.example @@ -0,0 +1,7 @@ +service_name: $CI_NAME +service_job_id: $CI_JOB_ID +service_build_url: $CI_BUILD_URL +service_branch: $CI_BRANCH +service_pull_request: $CI_PULL_REQUEST + +repo_token: $COVERALLS_REPO_TOKEN diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..79ef596 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: build +run-name: ${{ github.actor }} is making a build +on: + push: + branches: + - master +jobs: + test-coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Information + run: | + echo "Node.js" + node -v + echo "npm" + npm -v + - name: Install + run: npm ci + - name: Test + run: | + npm test + mkdir coverage + npm run test:report > coverage/test.lcov + - name: Publish test result to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index c5437e0..6bded22 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ lerna-debug.log* *.sw? # Test results +.coveralls.yml .nyc_output coverage diff --git a/.npmignore b/.npmignore index a89d02d..c70acbc 100644 --- a/.npmignore +++ b/.npmignore @@ -19,6 +19,7 @@ lerna-debug.log* # Test results .nyc_output +.coveralls.yml coverage # Common @@ -41,6 +42,8 @@ babel.config.* .nycrc .nycrc.* nyc.config.js +.coveralls.yml.example .travis.yml +.github /tests /src diff --git a/README.md b/README.md index 7ca430b..be43ca4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # dotenv-packed [![NPM version](https://img.shields.io/npm/v/dotenv-packed.svg?style=flat-square)](https://www.npmjs.com/package/dotenv-packed) -[![Travis (.org)](https://img.shields.io/travis/com/linhntaim/dotenv-packed?style=flat-square)](https://app.travis-ci.com/github/linhntaim/dotenv-packed) -[![Coveralls github](https://img.shields.io/coveralls/github/linhntaim/dotenv-packed?style=flat-square)](https://coveralls.io/github/linhntaim/dotenv-packed) -[![NPM](https://img.shields.io/npm/l/dotenv-packed?style=flat-square)](https://github.com/linhntaim/dotenv-packed/blob/master/LICENSE) +[![Github Actions](https://img.shields.io/github/actions/workflow/status/linhntaim/dotenv-packed/build.yml?style=flat-square)](https://github.com/linhntaim/dotenv-packed/actions/workflows/build.yml) +[![Coveralls](https://img.shields.io/coveralls/github/linhntaim/dotenv-packed?style=flat-square)](https://coveralls.io/github/linhntaim/dotenv-packed) +[![License](https://img.shields.io/npm/l/dotenv-packed?style=flat-square)](https://github.com/linhntaim/dotenv-packed/blob/master/LICENSE) All-in-one pack to load environment variables from `.env` file, then expand and convert them. Powered by diff --git a/dist/index.js b/dist/index.js index e8da3c2..6d4e538 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; var _dotenv = _interopRequireDefault(require("dotenv")); +var _dotenvConversion = _interopRequireDefault(require("dotenv-conversion")); var _dotenvExpand = _interopRequireDefault(require("dotenv-expand")); var _dotenvFlow = _interopRequireDefault(require("dotenv-flow")); -var _dotenvConversion = _interopRequireDefault(require("dotenv-conversion")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function load(useFlow, options) { if (useFlow) { diff --git a/package-lock.json b/package-lock.json index faef229..b178d92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "dotenv-packed", - "version": "3.0.1", + "version": "3.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dotenv-packed", - "version": "3.0.1", + "version": "3.1.0", "license": "MIT", "dependencies": { "dotenv": "^16.3.1", - "dotenv-conversion": "^3.0.0", + "dotenv-conversion": "^3.1.0", "dotenv-expand": "^10.0.0", "dotenv-flow": "^4.0.0" }, @@ -21,7 +21,7 @@ "@babel/register": "^7.22.15", "babel-plugin-add-module-exports": "^1.0.4", "chai": "^4.3.10", - "coveralls": "^3.1.1", + "coveralls-next": "^4.2.0", "mocha": "^10.2.0", "nyc": "^15.1.0" } @@ -1768,9 +1768,9 @@ } }, "node_modules/@babel/traverse": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.0.tgz", - "integrity": "sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, "dependencies": { "@babel/code-frame": "^7.22.13", @@ -1941,22 +1941,6 @@ "node": ">=8" } }, - "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -1966,6 +1950,15 @@ "node": ">=6" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -2018,24 +2011,6 @@ "sprintf-js": "~1.0.2" } }, - "node_modules/asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", - "dev": true, - "dependencies": { - "safer-buffer": "~2.1.0" - } - }, - "node_modules/assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true, - "engines": { - "node": ">=0.8" - } - }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -2051,21 +2026,6 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, - "node_modules/aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/aws4": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", - "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", - "dev": true - }, "node_modules/babel-plugin-add-module-exports": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-1.0.4.tgz", @@ -2126,15 +2086,6 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "node_modules/bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "dev": true, - "dependencies": { - "tweetnacl": "^0.14.3" - } - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -2220,9 +2171,9 @@ } }, "node_modules/caching-transform/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -2257,12 +2208,6 @@ } ] }, - "node_modules/caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, "node_modules/chai": { "version": "4.3.10", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", @@ -2432,15 +2377,6 @@ "wrap-ansi": "^7.0.0" } }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/cliui/node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -2560,29 +2496,64 @@ "url": "https://opencollective.com/core-js" } }, - "node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "node_modules/coveralls": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.1.1.tgz", - "integrity": "sha512-+dxnG2NHncSD1NrqbSM3dn/lE57O6Qf/koe9+I7c+wzkqRmEvcp0kgJdxKInzYzkICKkFMZsX3Vct3++tsF9ww==", + "node_modules/coveralls-next": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/coveralls-next/-/coveralls-next-4.2.0.tgz", + "integrity": "sha512-zg41a/4QDSASPtlV6gp+6owoU43U5CguxuPZR3nPZ26M5ZYdEK3MdUe7HwE+AnCZPkucudfhqqJZehCNkz2rYg==", "dev": true, "dependencies": { - "js-yaml": "^3.13.1", - "lcov-parse": "^1.0.0", - "log-driver": "^1.2.7", - "minimist": "^1.2.5", - "request": "^2.88.2" + "form-data": "4.0.0", + "js-yaml": "4.1.0", + "lcov-parse": "1.0.0", + "log-driver": "1.2.7", + "minimist": "1.2.7" }, "bin": { "coveralls": "bin/coveralls.js" }, "engines": { - "node": ">=6" + "node": ">=14" + } + }, + "node_modules/coveralls-next/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/coveralls-next/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/coveralls-next/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/coveralls-next/node_modules/minimist": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/cross-spawn": { @@ -2599,18 +2570,6 @@ "node": ">= 8" } }, - "node_modules/dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "dependencies": { - "assert-plus": "^1.0.0" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -2691,9 +2650,9 @@ } }, "node_modules/dotenv-conversion": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/dotenv-conversion/-/dotenv-conversion-3.0.0.tgz", - "integrity": "sha512-YzgV/BQHJQd1Zwa2zdJCtzv2pfwmG/evyioz/fdPlcWrAP9oNL3Y2tUbTIVuUz7H3xT8/Zma/La7ShHpKZPijA==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/dotenv-conversion/-/dotenv-conversion-3.1.0.tgz", + "integrity": "sha512-hqsR3OiNFu1L3hdHCPHBTSEHq33N/nagVGkidBVr3it5GfYgGxT+jXnH3XMPmJWr1esuJaxnJgUXL+fzLGSBWA==" }, "node_modules/dotenv-expand": { "version": "10.0.0", @@ -2714,16 +2673,6 @@ "node": ">= 12.0.0" } }, - "node_modules/ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "dev": true, - "dependencies": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, "node_modules/electron-to-chromium": { "version": "1.4.536", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.536.tgz", @@ -2782,33 +2731,6 @@ "node": ">=0.10.0" } }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "node_modules/extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true, - "engines": [ - "node >=0.6.0" - ] - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, "node_modules/find-cache-dir": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", @@ -2857,29 +2779,6 @@ "node": ">=8.0.0" } }, - "node_modules/forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "dev": true, - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 0.12" - } - }, "node_modules/fromentries": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", @@ -2912,20 +2811,6 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -2968,15 +2853,6 @@ "node": ">=8.0.0" } }, - "node_modules/getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "dependencies": { - "assert-plus": "^1.0.0" - } - }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -3012,29 +2888,6 @@ "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", "dev": true }, - "node_modules/har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "deprecated": "this library is no longer supported", - "dev": true, - "dependencies": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -3087,21 +2940,6 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, - "node_modules/http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "dev": true, - "dependencies": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - }, - "engines": { - "node": ">=0.8", - "npm": ">=1.3.7" - } - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -3241,12 +3079,6 @@ "node": ">=0.10.0" } }, - "node_modules/isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true - }, "node_modules/istanbul-lib-coverage": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", @@ -3284,9 +3116,9 @@ } }, "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3326,9 +3158,9 @@ } }, "node_modules/istanbul-lib-processinfo/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3373,9 +3205,9 @@ } }, "node_modules/istanbul-lib-report/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3448,12 +3280,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true - }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -3466,24 +3292,6 @@ "node": ">=4" } }, - "node_modules/json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "dev": true - }, - "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -3496,21 +3304,6 @@ "node": ">=6" } }, - "node_modules/jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "dev": true, - "engines": [ - "node >=0.6.0" - ], - "dependencies": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -3713,15 +3506,6 @@ "node": "*" } }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/mocha": { "version": "10.2.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", @@ -3999,15 +3783,6 @@ "node": ">=8.9" } }, - "node_modules/nyc/node_modules/ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/nyc/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -4152,9 +3927,9 @@ } }, "node_modules/nyc/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -4241,15 +4016,6 @@ "node": ">=6" } }, - "node_modules/oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -4361,12 +4127,6 @@ "node": "*" } }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true - }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -4427,30 +4187,6 @@ "node": ">=8" } }, - "node_modules/psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", - "dev": true - }, - "node_modules/punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", - "dev": true, - "engines": { - "node": ">=0.6" - } - }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -4555,38 +4291,6 @@ "node": ">=4" } }, - "node_modules/request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", - "dev": true, - "dependencies": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -4649,16 +4353,10 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, "node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" @@ -4779,9 +4477,9 @@ } }, "node_modules/spawn-wrap/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -4793,31 +4491,6 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "node_modules/sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "dev": true, - "dependencies": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - }, - "bin": { - "sshpk-conv": "bin/sshpk-conv", - "sshpk-sign": "bin/sshpk-sign", - "sshpk-verify": "bin/sshpk-verify" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", @@ -4886,37 +4559,6 @@ "node": ">=4" } }, - "node_modules/tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "dev": true, - "dependencies": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, - "node_modules/tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true - }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -5014,15 +4656,6 @@ "browserslist": ">= 4.21.0" } }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "dependencies": { - "punycode": "^2.1.0" - } - }, "node_modules/uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -5032,20 +4665,6 @@ "uuid": "bin/uuid" } }, - "node_modules/verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, - "engines": [ - "node >=0.6.0" - ], - "dependencies": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -5090,15 +4709,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi/node_modules/ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/wrap-ansi/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -5266,15 +4876,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/yargs/node_modules/ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/yargs/node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", diff --git a/package.json b/package.json index 1234847..5a2666c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dotenv-packed", - "version": "3.0.1", + "version": "3.1.0", "description": "All-in-one pack to load environment variables from .env file, then expand and convert them. Powered by `dotenv`/`dotenv-flow`, `dotenv-expand` and `dotenv-conversion`.", "main": "dist/index.js", "exports": { @@ -19,8 +19,11 @@ "scripts": { "build": "babel ./src -d ./dist -D --delete-dir-on-start", "test": "nyc mocha ./tests --require @babel/register", - "coverage": "nyc report --reporter=text-lcov | coveralls", - "ready": "npm i && npm run build && npm test" + "test:report": "nyc report --reporter=text-lcov", + "test:publish": "npm run test:report | coveralls", + "ci": "npm i && npm run build && npm test", + "cia": "npm run ci && npm run test:publish", + "cd": "npm run ci && npm publish" }, "repository": { "type": "git", @@ -48,7 +51,7 @@ "homepage": "https://github.com/linhntaim/dotenv-packed#readme", "dependencies": { "dotenv": "^16.3.1", - "dotenv-conversion": "^3.0.0", + "dotenv-conversion": "^3.1.0", "dotenv-expand": "^10.0.0", "dotenv-flow": "^4.0.0" }, @@ -59,7 +62,7 @@ "@babel/register": "^7.22.15", "babel-plugin-add-module-exports": "^1.0.4", "chai": "^4.3.10", - "coveralls": "^3.1.1", + "coveralls-next": "^4.2.0", "mocha": "^10.2.0", "nyc": "^15.1.0" } diff --git a/src/index.js b/src/index.js index 9859940..d754ba5 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import dotenv from 'dotenv' +import dotenvConversion from 'dotenv-conversion' import dotenvExpand from 'dotenv-expand' import dotenvFlow from 'dotenv-flow' -import dotenvConversion from 'dotenv-conversion' function load(useFlow, options) { if (useFlow) { diff --git a/tests/cli-options.js b/tests/cli-options.js index a5d8929..aab10eb 100644 --- a/tests/cli-options.js +++ b/tests/cli-options.js @@ -1,40 +1,59 @@ import chai from 'chai' -import cliOptions from '../dist/cli-options' import mocha from 'mocha' +import cliOptions from '../src/cli-options' -const after = mocha.after -const afterEach = mocha.afterEach +// const before = mocha.before +// const beforeEach = mocha.beforeEach +// const after = mocha.after +// const afterEach = mocha.afterEach const describe = mocha.describe const it = mocha.it const expect = chai.expect -chai.should() describe('cli-options', function () { + // before(() => { + // }) + // beforeEach(() => { + // }) + // after(() => { + // }) + // afterEach(() => { + // }) + describe('no-args', function () { it('no-args', function (done) { + // inputs const input = [] + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('no-passed-args', function (done) { + // inputs + + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = cliOptions() - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) @@ -42,8 +61,10 @@ describe('cli-options', function () { describe('dotenv', function () { it('path', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', 'dotenv_config_path=/custom/path/to/your/env/vars'] + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -51,16 +72,20 @@ describe('cli-options', function () { }, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('encoding', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', 'dotenv_config_encoding=latin1'] + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -68,16 +93,20 @@ describe('cli-options', function () { }, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('debug', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', 'dotenv_config_debug=true'] + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -85,16 +114,20 @@ describe('cli-options', function () { }, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('override', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', 'dotenv_config_override=true'] + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -102,16 +135,20 @@ describe('cli-options', function () { }, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('DOTENV_KEY', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', 'dotenv_config_DOTENV_KEY=dotenv://:key_1234…@dotenv.org/vault/.env.vault?environment=production'] + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -119,14 +156,17 @@ describe('cli-options', function () { }, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('option:empty', function (done) { + // inputs const input = [ 'node', '-e', @@ -138,19 +178,23 @@ describe('cli-options', function () { 'dotenv_config_DOTENV_KEY=', ] + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('option:case-sensitive', function (done) { + // inputs const input = [ 'node', '-e', @@ -162,29 +206,36 @@ describe('cli-options', function () { 'dotenv_config_dotenv_key=', ] + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('not-an-option', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', 'dotenv_config_foo=bar'] + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) @@ -192,38 +243,48 @@ describe('cli-options', function () { describe('dotenv-flow', function () { it('use-flow', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--use-flow'] + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:case-sensitive', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--USE-FLOW'] + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--use-flow', '--node-env', 'test'] + // expected outputs const expected = { useFlow: true, dotenvOptions: { @@ -231,46 +292,58 @@ describe('cli-options', function () { }, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env:empty', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--use-flow', '--node-env'] + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env:case-sensitive', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--use-flow', '--NODE-ENV', 'test'] + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env=', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--use-flow', '--node-env=test'] + // expected outputs const expected = { useFlow: true, dotenvOptions: { @@ -278,39 +351,49 @@ describe('cli-options', function () { }, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env=empty', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--use-flow', '--node-env='] + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env=case-sensitive', function (done) { + // inputs const input = ['node', '-e', '\'console.log(testing)\'', '--use-flow', '--NODE-ENV=test'] + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = cliOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) diff --git a/tests/config.js b/tests/config.js deleted file mode 100644 index 5685410..0000000 --- a/tests/config.js +++ /dev/null @@ -1,253 +0,0 @@ -import chai from 'chai' -import cp from 'child_process' -import mocha from 'mocha' -import path from 'path' -import fs from 'fs' -import dotenvPacked from '../dist' - -const before = mocha.before -const beforeEach = mocha.beforeEach -const after = mocha.after -const afterEach = mocha.afterEach -const describe = mocha.describe -const it = mocha.it -const expect = chai.expect -chai.should() - -describe('config', function () { - function spawn(cmd, options = {}) { - const {stdout} = cp.spawnSync( - process.argv[0], // node binary - cmd, - Object.assign( - {}, - { - cwd: path.resolve(__dirname, '..'), - timeout: 5000, - encoding: 'utf8', - }, - options, - ), - ) - - return stdout - } - - const indexLocalFile = './index.local.js' - before(() => { - console.log('before') - fs.copyFileSync(`./tests/inputs/index.local.js`, indexLocalFile) - }) - after(() => { - console.log('after') - fs.existsSync(indexLocalFile) && fs.rmSync(indexLocalFile) - }) - - describe('dotenv', function () { - const dotEnvFilePath = './.env' - after(() => { - fs.existsSync(dotEnvFilePath) && fs.rmSync(dotEnvFilePath) - }) - - function useEnv() { - fs.copyFileSync(`./tests/inputs/.env`, dotEnvFilePath) - } - - it('parsed:error', function (done) { - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - ], - ) - - output.should.equal('') - - done() - }) - - it('parsed', function (done) { - useEnv(true) - - const expected = '{\n' + - ' VARIABLE_1: \'variable 1\',\n' + - ' VARIABLE_2: \'variable 2\',\n' + - ' VARIABLE_NULL: null,\n' + - ' VARIABLE_UNDEFINED: undefined,\n' + - ' VARIABLE_BOOLEAN: true,\n' + - ' VARIABLE_NUMBER: 45,\n' + - ' VARIABLE_BIGINT: 1n,\n' + - ' VARIABLE_EMPTY: \'\',\n' + - ' VARIABLE_SYMBOL: Symbol(a),\n' + - ' VARIABLE_ARRAY: [ null, true, 45, \'x\' ],\n' + - ' VARIABLE_OBJECT: { a: null, b: true, c: 45, d: \'x\' },\n' + - ' VARIABLE_EXPAND: true\n' + - '}\n' - - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - ], - ) - - output.should.equal(expected) - - done() - }) - }) - - describe('dotenv-flow', function () { - const dotEnvFilePath = './.env' - after(() => { - fs.existsSync(dotEnvFilePath) && fs.rmSync(dotEnvFilePath) - fs.existsSync(`${dotEnvFilePath}.local`) && fs.rmSync(`${dotEnvFilePath}.local`) - fs.existsSync(`${dotEnvFilePath}.test`) && fs.rmSync(`${dotEnvFilePath}.test`) - fs.existsSync(`${dotEnvFilePath}.test.local`) && fs.rmSync(`${dotEnvFilePath}.test.local`) - }) - - function useEnv(level = 0) { - level === 1 && fs.copyFileSync(`./tests/inputs/flow.env`, dotEnvFilePath) - level > 1 && fs.copyFileSync(`./tests/inputs/flow.env.local`, `${dotEnvFilePath}.local`) - level > 2 && fs.copyFileSync(`./tests/inputs/flow.env.test`, `${dotEnvFilePath}.test`) - level > 3 && fs.copyFileSync(`./tests/inputs/flow.env.test.local`, `${dotEnvFilePath}.test.local`) - } - - it('flow:error', function (done) { - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - '--use-flow', - ], - ) - - output.should.equal('') - - done() - }) - - it('flow:env', function (done) { - useEnv(1) - - const expected = '{ VARIABLE_1: \'variable 1\', VARIABLE_2: \'variable 2\' }\n' - - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - '--use-flow', - ], - ) - - output.should.equal(expected) - - done() - }) - - it('flow:env.local', function (done) { - useEnv(2) - - const expected = '{ VARIABLE_1: \'local 1\', VARIABLE_2: \'local 2\' }\n' - - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - '--use-flow', - ], - ) - - output.should.equal(expected) - - done() - }) - - it('flow:env.test', function (done) { - useEnv(3) - - const expected = '{ VARIABLE_1: \'test 1\', VARIABLE_2: \'test 2\' }\n' - - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - '--use-flow', - '--node-env=test', - ], - ) - - output.should.equal(expected) - - done() - }) - - it('flow:env.test*2', function (done) { - useEnv(3) - - const expected = '{ VARIABLE_1: \'test 1\', VARIABLE_2: \'test 2\' }\n' - - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - '--use-flow', - '--node-env', - 'test', - ], - ) - - output.should.equal(expected) - - done() - }) - - it('flow:env.test.local', function (done) { - useEnv(4) - - const expected = '{ VARIABLE_1: \'test local 1\', VARIABLE_2: \'test local 2\' }\n' - - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - '--use-flow', - '--node-env=test', - ], - ) - - output.should.equal(expected) - - done() - }) - - it('flow:env.test.local*2', function (done) { - useEnv(4) - - const expected = '{ VARIABLE_1: \'test local 1\', VARIABLE_2: \'test local 2\' }\n' - - const output = spawn( - [ - '-r', - './config', - indexLocalFile, - '--use-flow', - '--node-env', - 'test', - ], - ) - - output.should.equal(expected) - - done() - }) - }) -}) diff --git a/tests/env-options.js b/tests/env-options.js index 9e440dc..db6b738 100644 --- a/tests/env-options.js +++ b/tests/env-options.js @@ -1,48 +1,62 @@ import chai from 'chai' -import envOptions from '../dist/env-options' import mocha from 'mocha' +import envOptions from '../src/env-options' -const before = mocha.before -const beforeEach = mocha.beforeEach -const after = mocha.after +// const before = mocha.before +// const beforeEach = mocha.beforeEach +// const after = mocha.after const afterEach = mocha.afterEach const describe = mocha.describe const it = mocha.it const expect = chai.expect -chai.should() const originEnv = {...process.env} describe('env-options', function () { + // before(() => { + // }) + // beforeEach(() => { + // }) + // after(() => { + // }) afterEach(() => { process.env = {...originEnv} }) - + describe('no-env', function () { it('no-env', function (done) { + // inputs const input = {} + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(input) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('no-passed-env', function (done) { + // inputs + + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions() - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) @@ -50,8 +64,10 @@ describe('env-options', function () { describe('dotenv', function () { it('path', function (done) { + // inputs process.env.DOTENV_CONFIG_PATH = '/custom/path/to/your/env/vars' + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -59,16 +75,20 @@ describe('env-options', function () { }, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('encoding', function (done) { + // inputs process.env.DOTENV_CONFIG_ENCODING = 'latin1' + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -76,16 +96,20 @@ describe('env-options', function () { }, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('debug', function (done) { + // inputs process.env.DOTENV_CONFIG_DEBUG = 'true' + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -93,16 +117,20 @@ describe('env-options', function () { }, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('override', function (done) { + // inputs process.env.DOTENV_CONFIG_OVERRIDE = 'true' + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -110,16 +138,20 @@ describe('env-options', function () { }, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('DOTENV_KEY', function (done) { + // inputs process.env.DOTENV_CONFIG_DOTENV_KEY = 'dotenv://:key_1234…@dotenv.org/vault/.env.vault?environment=production' + // expected outputs const expected = { useFlow: false, dotenvOptions: { @@ -127,41 +159,52 @@ describe('env-options', function () { }, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('empty', function (done) { + // inputs process.env.DOTENV_CONFIG_PATH = '' process.env.DOTENV_CONFIG_ENCODING = '' process.env.DOTENV_CONFIG_DEBUG = '' process.env.DOTENV_CONFIG_OVERRIDE = '' process.env.DOTENV_CONFIG_DOTENV_KEY = '' + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('not-set', function (done) { + // inputs + + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) @@ -169,143 +212,181 @@ describe('env-options', function () { describe('dotenv-flow', function () { it('use-flow', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = 'true' + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:false', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = 'false' + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:no', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = 'no' + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:not', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = 'not' + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:none', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = 'none' + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:0', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = '0.1' + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:.', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = '.1' + // expected outputs const expected = { useFlow: false, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:any', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = '1.1' + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('use-flow:empty', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = '' + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = '' process.env.NODE_ENV = 'test' + // expected outputs const expected = { useFlow: true, dotenvOptions: { @@ -313,40 +394,50 @@ describe('env-options', function () { }, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env:empty', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = '' process.env.NODE_ENV = '' + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) it('node_env:not-set', function (done) { + // inputs process.env.DOTENV_PACKED_USE_FLOW = '' + // expected outputs const expected = { useFlow: true, dotenvOptions: {}, } + // executes const options = envOptions(process.env) - options.should.deep.equal(expected) + // asserts + expect(options).to.deep.equal(expected) done() }) diff --git a/tests/index.js b/tests/index.js index 54c262b..e6b4488 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,18 +1,25 @@ import chai from 'chai' -import dotenvPacked from '../dist' import fs from 'fs' import mocha from 'mocha' +import dotenvPacked from '../src' +// const before = mocha.after +// const beforeEach = mocha.beforeEach const after = mocha.after const afterEach = mocha.afterEach const describe = mocha.describe const it = mocha.it const expect = chai.expect -chai.should() const originEnv = {...process.env} describe('dotenv-packed', function () { + // before(() => { + // }) + // beforeEach(() => { + // }) + // after(() => { + // }) afterEach(() => { process.env = {...originEnv} }) @@ -25,6 +32,7 @@ describe('dotenv-packed', function () { } it('parsed', function (done) { + // inputs const input = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -43,6 +51,7 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -73,6 +82,7 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {parsed, get} = dotenvPacked.pack( Object.assign( @@ -89,18 +99,20 @@ describe('dotenv-packed', function () { ), ) - parsed.should.deep.include(expected) - parsed.VARIABLE_SYMBOL.should.be.a('symbol') - parsed.VARIABLE_SYMBOL.toString().should.equal(expectedVariableSymbol.toString()) - parsed.should.not.haveOwnProperty('CONVERSION') - process.env.should.deep.include(expectedProcessEnv) - process.env.should.not.haveOwnProperty('CONVERSION') + // asserts + expect(parsed).to.deep.include(expected) + expect(parsed.VARIABLE_SYMBOL).to.be.a('symbol') + expect(parsed.VARIABLE_SYMBOL.toString()).to.equal(expectedVariableSymbol.toString()) + expect(parsed).to.not.haveOwnProperty('CONVERSION') + expect(process.env).to.deep.include(expectedProcessEnv) + expect(process.env).to.not.haveOwnProperty('CONVERSION') expect(get('VARIABLE_1000')).to.be.a('null') done() }) it('parsed:ignore-process-env', function (done) { + // inputs const input = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -119,6 +131,7 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -137,6 +150,7 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {parsed, get} = dotenvPacked.pack( Object.assign( @@ -154,29 +168,31 @@ describe('dotenv-packed', function () { ), ) - parsed.should.deep.include(expected) - parsed.VARIABLE_SYMBOL.should.be.a('symbol') - parsed.VARIABLE_SYMBOL.toString().should.equal(expectedVariableSymbol.toString()) - parsed.should.not.haveOwnProperty('CONVERSION') - process.env.should.deep.include(expectedProcessEnv) - process.env.should.not.haveOwnProperty('CONVERSION') - process.env.should.not.haveOwnProperty('VARIABLE_1') - process.env.should.not.haveOwnProperty('VARIABLE_2') - process.env.should.not.haveOwnProperty('VARIABLE_NULL') - process.env.should.not.haveOwnProperty('VARIABLE_UNDEFINED') - process.env.should.not.haveOwnProperty('VARIABLE_BOOLEAN') - process.env.should.not.haveOwnProperty('VARIABLE_NUMBER') - process.env.should.not.haveOwnProperty('VARIABLE_BIGINT') - process.env.should.not.haveOwnProperty('VARIABLE_EMPTY') - process.env.should.not.haveOwnProperty('VARIABLE_ARRAY') - process.env.should.not.haveOwnProperty('VARIABLE_OBJECT') - process.env.should.not.haveOwnProperty('VARIABLE_EXPAND') + // asserts + expect(parsed).to.deep.include(expected) + expect(parsed.VARIABLE_SYMBOL).to.be.a('symbol') + expect(parsed.VARIABLE_SYMBOL.toString()).to.equal(expectedVariableSymbol.toString()) + expect(parsed).to.not.haveOwnProperty('CONVERSION') + expect(process.env).to.deep.include(expectedProcessEnv) + expect(process.env).to.not.haveOwnProperty('CONVERSION') + expect(process.env).to.not.haveOwnProperty('VARIABLE_1') + expect(process.env).to.not.haveOwnProperty('VARIABLE_2') + expect(process.env).to.not.haveOwnProperty('VARIABLE_NULL') + expect(process.env).to.not.haveOwnProperty('VARIABLE_UNDEFINED') + expect(process.env).to.not.haveOwnProperty('VARIABLE_BOOLEAN') + expect(process.env).to.not.haveOwnProperty('VARIABLE_NUMBER') + expect(process.env).to.not.haveOwnProperty('VARIABLE_BIGINT') + expect(process.env).to.not.haveOwnProperty('VARIABLE_EMPTY') + expect(process.env).to.not.haveOwnProperty('VARIABLE_ARRAY') + expect(process.env).to.not.haveOwnProperty('VARIABLE_OBJECT') + expect(process.env).to.not.haveOwnProperty('VARIABLE_EXPAND') expect(get('VARIABLE_1000')).to.be.a('null') done() }) it('get a variable', function (done) { + // inputs const input = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -195,6 +211,7 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -225,36 +242,38 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {get} = dotenvPacked.pack(useEnv(input)) + // asserts // existent variable - get('VARIABLE_1').should.equal(expected.VARIABLE_1) - get('VARIABLE_2').should.equal(expected.VARIABLE_2) + expect(get('VARIABLE_1')).to.equal(expected.VARIABLE_1) + expect(get('VARIABLE_2')).to.equal(expected.VARIABLE_2) expect(get('VARIABLE_NULL')).to.be.a('null') expect(get('VARIABLE_NULL', 'default null')).to.be.a('null') expect(get('VARIABLE_UNDEFINED')).to.be.an('undefined') expect(get('VARIABLE_UNDEFINED', 'default undefined')).to.be.an('undefined') - get('VARIABLE_BOOLEAN').should.equal(expected.VARIABLE_BOOLEAN) - get('VARIABLE_NUMBER').should.equal(expected.VARIABLE_NUMBER) - get('VARIABLE_BIGINT').should.equal(expected.VARIABLE_BIGINT) - get('VARIABLE_EMPTY').should.equal(expected.VARIABLE_EMPTY) - get('VARIABLE_EMPTY', 'default empty').should.equal(expected.VARIABLE_EMPTY) - get('VARIABLE_SYMBOL').should.be.a('symbol') - get('VARIABLE_SYMBOL').toString().should.equal(expectedVariableSymbol.toString()) - get('VARIABLE_ARRAY').should.deep.equal(expected.VARIABLE_ARRAY) - get('VARIABLE_OBJECT').should.deep.equal(expected.VARIABLE_OBJECT) - get('VARIABLE_100').should.equal(expectedProcessEnv.VARIABLE_100) - + expect(get('VARIABLE_BOOLEAN')).to.equal(expected.VARIABLE_BOOLEAN) + expect(get('VARIABLE_NUMBER')).to.equal(expected.VARIABLE_NUMBER) + expect(get('VARIABLE_BIGINT')).to.equal(expected.VARIABLE_BIGINT) + expect(get('VARIABLE_EMPTY')).to.equal(expected.VARIABLE_EMPTY) + expect(get('VARIABLE_EMPTY', 'default empty')).to.equal(expected.VARIABLE_EMPTY) + expect(get('VARIABLE_SYMBOL')).to.be.a('symbol') + expect(get('VARIABLE_SYMBOL').toString()).to.equal(expectedVariableSymbol.toString()) + expect(get('VARIABLE_ARRAY')).to.deep.equal(expected.VARIABLE_ARRAY) + expect(get('VARIABLE_OBJECT')).to.deep.equal(expected.VARIABLE_OBJECT) + expect(get('VARIABLE_100')).to.equal(expectedProcessEnv.VARIABLE_100) // non-existent variable expect(process.env.VARIABLE_3).to.be.an('undefined') expect(get('VARIABLE_3')).to.be.a('null') - get('VARIABLE_3', 'default 3').should.equal('default 3') + get('VARIABLE_3', expect('default 3')).to.equal('default 3') done() }) it('get all', function (done) { + // inputs const input = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -273,6 +292,7 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -317,28 +337,33 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {get} = dotenvPacked.pack(useEnv(input)) + // asserts // all - get().should.deep.include(expectedAll) - get().VARIABLE_SYMBOL.should.be.a('symbol') - get().VARIABLE_SYMBOL.toString().should.equal(expectedVariableSymbol.toString()) + expect(get()).to.deep.include(expectedAll) + expect(get().VARIABLE_SYMBOL).to.be.a('symbol') + expect(get().VARIABLE_SYMBOL.toString()).to.equal(expectedVariableSymbol.toString()) // all with default values - get( - null, - { - VARIABLE_NULL: 'default null', - VARIABLE_UNDEFINED: 'default undefined', - VARIABLE_EMPTY: 'default empty', - VARIABLE_3: 'default 3', - }, - ).should.deep.include(Object.assign({}, expectedAll, {VARIABLE_3: 'default 3'})) + expect( + get( + null, + { + VARIABLE_NULL: 'default null', + VARIABLE_UNDEFINED: 'default undefined', + VARIABLE_EMPTY: 'default empty', + VARIABLE_3: 'default 3', + }, + ), + ).to.deep.include(Object.assign({}, expectedAll, {VARIABLE_3: 'default 3'})) done() }) it('get only', function (done) { + // inputs const input = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -357,6 +382,7 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -394,36 +420,42 @@ describe('dotenv-packed', function () { VARIABLE_EMPTY: '', } + // executes Object.assign(process.env, inputProcessEnv) const {get} = dotenvPacked.pack(useEnv(input)) + // asserts // only with existent variables - get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY']).should.deep.equal(expectedOnly) + expect(get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY'])).to.deep.equal(expectedOnly) // only with existent variables and non-existent variables - get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3']).should.deep.equal( + expect(get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3'])).to.deep.equal( Object.assign({}, expectedOnly, {VARIABLE_3: null}), ) // only with existent variables and non-existent variables which have default values - get( - ['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3'], - { + expect( + get( + ['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3'], + { + VARIABLE_1: 'default 1', + VARIABLE_2: 'default 2', + VARIABLE_NULL: 'default null', + VARIABLE_UNDEFINED: 'default undefined', + VARIABLE_EMPTY: 'default empty', + VARIABLE_3: 'default 3', + }, + ), + ).to.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) + // only with existent variables and non-existent variables which have default values 2 + expect( + get({ VARIABLE_1: 'default 1', VARIABLE_2: 'default 2', VARIABLE_NULL: 'default null', VARIABLE_UNDEFINED: 'default undefined', VARIABLE_EMPTY: 'default empty', VARIABLE_3: 'default 3', - }, - ).should.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) - // only with existent variables and non-existent variables which have default values 2 - get({ - VARIABLE_1: 'default 1', - VARIABLE_2: 'default 2', - VARIABLE_NULL: 'default null', - VARIABLE_UNDEFINED: 'default undefined', - VARIABLE_EMPTY: 'default empty', - VARIABLE_3: 'default 3', - }).should.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) + }), + ).to.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) done() }) @@ -444,10 +476,12 @@ describe('dotenv-packed', function () { } it('parsed:error', function (done) { + // inputs const inputProcessEnv = { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -479,21 +513,25 @@ describe('dotenv-packed', function () { } try { + // executes Object.assign(process.env, inputProcessEnv) const {parsed} = useEnv(false) } catch (e) { - e.should.equal('Cannot load .env file') + // asserts + expect(e).to.equal('Cannot load .env file') } done() }) it('parsed', function (done) { + // inputs const inputProcessEnv = { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -524,22 +562,26 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {parsed} = useEnv() - parsed.should.deep.include(expected) - parsed.VARIABLE_SYMBOL.should.be.a('symbol') - parsed.VARIABLE_SYMBOL.toString().should.equal(expectedVariableSymbol.toString()) - process.env.should.deep.include(expectedProcessEnv) + // asserts + expect(parsed).to.deep.include(expected) + expect(parsed.VARIABLE_SYMBOL).to.be.a('symbol') + expect(parsed.VARIABLE_SYMBOL.toString()).to.equal(expectedVariableSymbol.toString()) + expect(process.env).to.deep.include(expectedProcessEnv) done() }) it('get a variable', function (done) { + // inputs const inputProcessEnv = { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -570,40 +612,43 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {get} = useEnv() + // asserts // existent variable - get('VARIABLE_1').should.equal(expected.VARIABLE_1) - get('VARIABLE_2').should.equal(expected.VARIABLE_2) + expect(get('VARIABLE_1')).to.equal(expected.VARIABLE_1) + expect(get('VARIABLE_2')).to.equal(expected.VARIABLE_2) expect(get('VARIABLE_NULL')).to.be.a('null') expect(get('VARIABLE_NULL', 'default null')).to.be.a('null') expect(get('VARIABLE_UNDEFINED')).to.be.an('undefined') expect(get('VARIABLE_UNDEFINED', 'default undefined')).to.be.an('undefined') - get('VARIABLE_BOOLEAN').should.equal(expected.VARIABLE_BOOLEAN) - get('VARIABLE_NUMBER').should.equal(expected.VARIABLE_NUMBER) - get('VARIABLE_BIGINT').should.equal(expected.VARIABLE_BIGINT) - get('VARIABLE_EMPTY').should.equal(expected.VARIABLE_EMPTY) - get('VARIABLE_EMPTY', 'default empty').should.equal(expected.VARIABLE_EMPTY) - get('VARIABLE_SYMBOL').should.be.a('symbol') - get('VARIABLE_SYMBOL').toString().should.equal(expectedVariableSymbol.toString()) - get('VARIABLE_ARRAY').should.deep.equal(expected.VARIABLE_ARRAY) - get('VARIABLE_OBJECT').should.deep.equal(expected.VARIABLE_OBJECT) - get('VARIABLE_100').should.equal(expectedProcessEnv.VARIABLE_100) - + expect(get('VARIABLE_BOOLEAN')).to.equal(expected.VARIABLE_BOOLEAN) + expect(get('VARIABLE_NUMBER')).to.equal(expected.VARIABLE_NUMBER) + expect(get('VARIABLE_BIGINT')).to.equal(expected.VARIABLE_BIGINT) + expect(get('VARIABLE_EMPTY')).to.equal(expected.VARIABLE_EMPTY) + expect(get('VARIABLE_EMPTY', 'default empty')).to.equal(expected.VARIABLE_EMPTY) + expect(get('VARIABLE_SYMBOL')).to.be.a('symbol') + expect(get('VARIABLE_SYMBOL').toString()).to.equal(expectedVariableSymbol.toString()) + expect(get('VARIABLE_ARRAY')).to.deep.equal(expected.VARIABLE_ARRAY) + expect(get('VARIABLE_OBJECT')).to.deep.equal(expected.VARIABLE_OBJECT) + expect(get('VARIABLE_100')).to.equal(expectedProcessEnv.VARIABLE_100) // non-existent variable expect(process.env.VARIABLE_3).to.be.an('undefined') expect(get('VARIABLE_3')).to.be.a('null') - get('VARIABLE_3', 'default 3').should.equal('default 3') + get('VARIABLE_3', expect('default 3')).to.equal('default 3') done() }) it('get all', function (done) { + // inputs const inputProcessEnv = { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -648,32 +693,38 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {get} = dotenvPacked.pack(useEnv()) + // asserts // all - get().should.deep.include(expectedAll) - get().VARIABLE_SYMBOL.should.be.a('symbol') - get().VARIABLE_SYMBOL.toString().should.equal(expectedVariableSymbol.toString()) + expect(get()).to.deep.include(expectedAll) + expect(get().VARIABLE_SYMBOL).to.be.a('symbol') + expect(get().VARIABLE_SYMBOL.toString()).to.equal(expectedVariableSymbol.toString()) // all with default values - get( - null, - { - VARIABLE_NULL: 'default null', - VARIABLE_UNDEFINED: 'default undefined', - VARIABLE_EMPTY: 'default empty', - VARIABLE_3: 'default 3', - }, - ).should.deep.include(Object.assign({}, expectedAll, {VARIABLE_3: 'default 3'})) + expect( + get( + null, + { + VARIABLE_NULL: 'default null', + VARIABLE_UNDEFINED: 'default undefined', + VARIABLE_EMPTY: 'default empty', + VARIABLE_3: 'default 3', + }, + ), + ).to.deep.include(Object.assign({}, expectedAll, {VARIABLE_3: 'default 3'})) done() }) it('get only', function (done) { + // inputs const inputProcessEnv = { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -711,36 +762,42 @@ describe('dotenv-packed', function () { VARIABLE_EMPTY: '', } + // executes Object.assign(process.env, inputProcessEnv) const {get} = useEnv() + // asserts // only with existent variables - get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY']).should.deep.equal(expectedOnly) + expect(get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY'])).to.deep.equal(expectedOnly) // only with existent variables and non-existent variables - get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3']).should.deep.equal( + expect(get(['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3'])).to.deep.equal( Object.assign({}, expectedOnly, {VARIABLE_3: null}), ) // only with existent variables and non-existent variables which have default values - get( - ['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3'], - { + expect( + get( + ['VARIABLE_1', 'VARIABLE_2', 'VARIABLE_NULL', 'VARIABLE_UNDEFINED', 'VARIABLE_EMPTY', 'VARIABLE_3'], + { + VARIABLE_1: 'default 1', + VARIABLE_2: 'default 2', + VARIABLE_NULL: 'default null', + VARIABLE_UNDEFINED: 'default undefined', + VARIABLE_EMPTY: 'default empty', + VARIABLE_3: 'default 3', + }, + ), + ).to.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) + // only with existent variables and non-existent variables which have default values 2 + expect( + get({ VARIABLE_1: 'default 1', VARIABLE_2: 'default 2', VARIABLE_NULL: 'default null', VARIABLE_UNDEFINED: 'default undefined', VARIABLE_EMPTY: 'default empty', VARIABLE_3: 'default 3', - }, - ).should.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) - // only with existent variables and non-existent variables which have default values 2 - get({ - VARIABLE_1: 'default 1', - VARIABLE_2: 'default 2', - VARIABLE_NULL: 'default null', - VARIABLE_UNDEFINED: 'default undefined', - VARIABLE_EMPTY: 'default empty', - VARIABLE_3: 'default 3', - }).should.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) + }), + ).to.deep.equal(Object.assign({}, expectedOnly, {VARIABLE_3: 'default 3'})) done() }) @@ -764,11 +821,13 @@ describe('dotenv-packed', function () { } it('flow:error', function (done) { + // inputs const input = 0 const inputProcessEnv = { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -779,22 +838,26 @@ describe('dotenv-packed', function () { } try { + // executes Object.assign(process.env, inputProcessEnv) const {parsed} = useEnv(input) } catch (e) { - e.should.equal('Cannot load .env file') + // asserts + expect(e).to.equal('Cannot load .env file') } done() }) it('flow:env', function (done) { + // inputs const input = 1 const inputProcessEnv = { VARIABLE_100: 'variable 100', } + // expected outputs const expected = { VARIABLE_1: 'variable 1', VARIABLE_2: 'variable 2', @@ -804,21 +867,25 @@ describe('dotenv-packed', function () { VARIABLE_100: 'variable 100', } + // executes Object.assign(process.env, inputProcessEnv) const {parsed} = useEnv(input) - parsed.should.deep.equal(expected) - process.env.should.deep.include(expectedProcessEnv) + // asserts + expect(parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedProcessEnv) done() }) it('flow:env.local', function (done) { + // inputs const input = 2 const inputProcessEnv = { VARIABLE_100: 'local 100', } + // expected outputs const expected = { VARIABLE_1: 'local 1', VARIABLE_2: 'local 2', @@ -828,22 +895,26 @@ describe('dotenv-packed', function () { VARIABLE_100: 'local 100', } + // executes Object.assign(process.env, inputProcessEnv) const {parsed} = useEnv(input) - parsed.should.deep.equal(expected) - process.env.should.deep.include(expectedProcessEnv) + // asserts + expect(parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedProcessEnv) done() }) it('flow:env.test', function (done) { + // inputs process.env.NODE_ENV = 'test' const input = 3 const inputProcessEnv = { VARIABLE_100: 'test 100', } + // expected outputs const expected = { VARIABLE_1: 'test 1', VARIABLE_2: 'test 2', @@ -853,22 +924,26 @@ describe('dotenv-packed', function () { VARIABLE_100: 'test 100', } + // executes Object.assign(process.env, inputProcessEnv) const {parsed} = useEnv(input) - parsed.should.deep.equal(expected) - process.env.should.deep.include(expectedProcessEnv) + // asserts + expect(parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedProcessEnv) done() }) it('flow:env.test.local', function (done) { + // inputs process.env.NODE_ENV = 'test' const input = 4 const inputProcessEnv = { VARIABLE_100: 'test local 100', } + // expected outputs const expected = { VARIABLE_1: 'test local 1', VARIABLE_2: 'test local 2', @@ -878,11 +953,13 @@ describe('dotenv-packed', function () { VARIABLE_100: 'test local 100', } + // executes Object.assign(process.env, inputProcessEnv) const {parsed} = useEnv(input) - parsed.should.deep.equal(expected) - process.env.should.deep.include(expectedProcessEnv) + // asserts + expect(parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedProcessEnv) done() })