From df0687396ca79e8600bdd896115855223332524e Mon Sep 17 00:00:00 2001 From: Nguyen Tuan Linh Date: Fri, 3 Nov 2023 18:28:39 +0700 Subject: [PATCH] + feature: options to disable the support binary/octal/hexadecimal format in conversion --- README.md | 58 + dist/index.js | 121 +- src/index.js | 131 +- tests/index.js | 1376 ++++++++++++++++- tests/inputs/method.auto.bigint.boh.false.env | 18 + tests/inputs/method.auto.number.boh.false.env | 18 + tests/inputs/method.bigint.boh.false.env | 37 + tests/inputs/method.boolean.boh.false.env | 75 + tests/inputs/method.number.boh.false.env | 37 + 9 files changed, 1754 insertions(+), 117 deletions(-) create mode 100644 tests/inputs/method.auto.bigint.boh.false.env create mode 100644 tests/inputs/method.auto.number.boh.false.env create mode 100644 tests/inputs/method.bigint.boh.false.env create mode 100644 tests/inputs/method.boolean.boh.false.env create mode 100644 tests/inputs/method.number.boh.false.env diff --git a/README.md b/README.md index 94a36cd..a8bbed0 100644 --- a/README.md +++ b/README.md @@ -468,6 +468,10 @@ console.log(process.env.VARIABLE_24) // (string) '10' console.log(process.env.VARIABLE_25) // (string) '-10' ``` +***Note:* You can disable the support for binary, octal or hexadecimal number format +by setting the option [`binaryNumber`](#binarynumber), +[`octalNumber`](#octalnumber) or [`hexadecimalNumber`](#hexadecimalnumber) to false. + - **bigint** Values to be converted to bigint must match the format: `${value}n`; @@ -518,6 +522,10 @@ console.log(process.env.VARIABLE_8) // (string) '10n' console.log(process.env.VARIABLE_9) // (string) '10n' ``` +***Note:* You can disable the support for binary, octal or hexadecimal bigint format +by setting the option [`binaryBigInt`](#binarybigint), +[`octalBigInt`](#octalbigint) or [`hexadecimalBigInt`](#hexadecimalbigint) to false. + - **symbol** Values to be converted to symbol must match the format: `Symbol(${string})`. @@ -850,6 +858,10 @@ console.log(process.env.VARIABLE_25) // (string) '10' console.log(process.env.VARIABLE_26) // (string) '0' ``` +***Note:* You can disable the conversion for binary, octal or hexadecimal number format +by setting the option [`binaryNumber`](#binarynumber), +[`octalNumber`](#octalnumber) or [`hexadecimalNumber`](#hexadecimalnumber) to false. + - **bigint** This method is to convert any value to bigint. @@ -953,6 +965,10 @@ console.log(process.env.VARIABLE_27) // (string) '10n' console.log(process.env.VARIABLE_28) // (string) '0n' ``` +***Note:* You can disable the conversion for binary, octal or hexadecimal bigint format +by setting the option [`binaryBigInt`](#binarybigint), +[`octalBigInt`](#octalbigint) or [`hexadecimalBigInt`](#hexadecimalbigint) to false. + - **string** This method is to keep any value as it is. @@ -1740,6 +1756,48 @@ If this option is set to `true`, they won't. See [this feature](#ignore-processenv). +##### `binaryNumber` + +*Type:* `boolean`. *Default:* `true`. + +If this option is set to `false`, the string in binary number format +will not be converted to number. + +##### `octalNumber` + +*Type:* `boolean`. *Default:* `true`. + +If this option is set to `false`, the string in octal number format +will not be converted to number. + +##### `hexadecimalNumber` + +*Type:* `boolean`. *Default:* `true`. + +If this option is set to `false`, the string in hexadecimal number format +will not be converted to number. + +##### `binaryBigInt` + +*Type:* `boolean`. *Default:* `true`. + +If this option is set to `false`, the string in binary bigint format +will not be converted to bigint. + +##### `octalBigInt` + +*Type:* `boolean`. *Default:* `true`. + +If this option is set to `false`, the string in octal bigint format +will not be converted to bigint. + +##### `hexadecimalBigInt` + +*Type:* `boolean`. *Default:* `true`. + +If this option is set to `false`, the string in hexadecimal bigint format +will not be converted to bigint. + ##### `prevents` *Type:* `array`. *Default:* `[]`. diff --git a/dist/index.js b/dist/index.js index 74fd0de..3c59d8e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10,9 +10,13 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == */ var NUMBER_REGEX = /^[+-]?(\d+(\.(\d*)?)?|\.\d+)([eE][+-]?\d+)?$/; -var NUM_BOH_REGEX = /^[+-]?0([bB][01]+|[oO][0-8]+|[xX][0-9a-fA-F]+)$/; +var NUM_BIN_REGEX = /^[+-]?0[bB][01]+$/; +var NUM_OCT_REGEX = /^[+-]?0[oO][0-8]+$/; +var NUM_HEX_REGEX = /^[+-]?0[xX][0-9a-fA-F]+$/; var BIGINT_REGEX = /^[+-]?\d+n$/; -var BIG_BOH_REGEX = /^[+-]?0([bB][01]+|[oO][0-8]+|[xX][0-9a-fA-F]+)n$/; +var BIG_BIN_REGEX = /^[+-]?0[bB][01]+n$/; +var BIG_OCT_REGEX = /^[+-]?0[oO][0-8]+n$/; +var BIG_HEX_REGEX = /^[+-]?0[xX][0-9a-fA-F]+n$/; var SYMBOL_REGEX = /^Symbol\(.*\)$/; var ARRAY_REGEX = /^\[.*]$/; var ARRAY_EMPTY_REGEX = /^\[\s*]$/; @@ -71,9 +75,14 @@ function parseNumber(str) { /** * * @param {string} str - * @returns {number} + * @param {boolean} parsed + * @returns {number|string} */ function parseBohNumber(str) { + var parsed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + if (!parsed) { + return str; + } switch (str[0]) { case '+': return Number(str.substring(1)); @@ -96,9 +105,14 @@ function parseBigInt(str) { /** * * @param {string} str - * @returns {bigint} + * @param {boolean} parsed + * @returns {bigint|string} */ function parseBohBigInt(str) { + var parsed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + if (!parsed) { + return str; + } switch (str[0]) { case '+': return BigInt(str.slice(1, -1)); @@ -130,18 +144,19 @@ function parseSymbol(str) { /** * * @param {string|*} value - * @param {object} valueTable - * @param {boolean} fromDotEnv + * @param {object} config * @returns {null|undefined|boolean|number|bigint|string|symbol|array|object} */ -function restoreValue(value, valueTable, fromDotEnv) { +function restoreValue(value, config) { if (!(typeof value == 'string' || value instanceof String)) { return value; } - if (fromDotEnv) { + if (config.fromDotEnv) { value = unescapeValue(value); } var trimmed = value.trim(); + // defined values + var valueTable = config._cache.valueTables.forAutoForced; if (trimmed in valueTable) { return valueTable[trimmed]; } @@ -149,15 +164,27 @@ function restoreValue(value, valueTable, fromDotEnv) { if (NUMBER_REGEX.test(trimmed)) { return parseNumber(trimmed); } - if (NUM_BOH_REGEX.test(trimmed)) { - return parseBohNumber(trimmed); + if (NUM_BIN_REGEX.test(trimmed)) { + return parseBohNumber(trimmed, config.binaryNumber); + } + if (NUM_OCT_REGEX.test(trimmed)) { + return parseBohNumber(trimmed, config.octalNumber); + } + if (NUM_HEX_REGEX.test(trimmed)) { + return parseBohNumber(trimmed, config.hexadecimalNumber); } // BigInt if (BIGINT_REGEX.test(trimmed)) { return parseBigInt(trimmed); } - if (BIG_BOH_REGEX.test(trimmed)) { - return parseBohBigInt(trimmed); + if (BIG_BIN_REGEX.test(trimmed)) { + return parseBohBigInt(trimmed, config.binaryBigInt); + } + if (BIG_OCT_REGEX.test(trimmed)) { + return parseBohBigInt(trimmed, config.octalBigInt); + } + if (BIG_HEX_REGEX.test(trimmed)) { + return parseBohBigInt(trimmed, config.hexadecimalBigInt); } // Symbol if (SYMBOL_REGEX.test(trimmed)) { @@ -222,11 +249,17 @@ function defaultConfig() { parsed: {}, fromDotEnv: true, ignoreProcessEnv: false, + binaryNumber: true, + octalNumber: true, + hexadecimalNumber: true, + binaryBigInt: true, + octalBigInt: true, + hexadecimalBigInt: true, prevents: [], specs: {}, methods: { auto: function auto(value, name, config) { - value = restoreValue(value, config._cache.valueTables.forAutoForced, config.fromDotEnv); + value = restoreValue(value, config); if (typeof value === 'string') { var lTrimmed = value.replace(/^\s+/, ''); var findPossibleMethod = function findPossibleMethod(methods) { @@ -261,13 +294,13 @@ function defaultConfig() { if (NUMBER_REGEX.test(value)) { return parseNumber(value) !== 0; } - if (NUM_BOH_REGEX.test(value)) { + if (NUM_BIN_REGEX.test(value) || NUM_OCT_REGEX.test(value) || NUM_HEX_REGEX.test(value)) { return parseBohNumber(value) !== 0; } if (BIGINT_REGEX.test(value)) { return parseBigInt(value) !== 0n; } - if (BIG_BOH_REGEX.test(value)) { + if (BIG_BIN_REGEX.test(value) || BIG_OCT_REGEX.test(value) || BIG_HEX_REGEX.test(value)) { return parseBohBigInt(value) !== 0n; } return true; @@ -284,14 +317,26 @@ function defaultConfig() { if (NUMBER_REGEX.test(value)) { return parseNumber(value); } - if (NUM_BOH_REGEX.test(value)) { - return parseBohNumber(value); + if (NUM_BIN_REGEX.test(value)) { + return parseBohNumber(value, config.binaryNumber); + } + if (NUM_OCT_REGEX.test(value)) { + return parseBohNumber(value, config.octalNumber); + } + if (NUM_HEX_REGEX.test(value)) { + return parseBohNumber(value, config.hexadecimalNumber); } if (BIGINT_REGEX.test(value)) { return parseNumber(value.slice(0, -1)); } - if (BIG_BOH_REGEX.test(value)) { - return parseBohNumber(value.slice(0, -1)); + if (BIG_BIN_REGEX.test(value)) { + return parseBohNumber(value.slice(0, -1), config.binaryNumber); + } + if (BIG_OCT_REGEX.test(value)) { + return parseBohNumber(value.slice(0, -1), config.octalNumber); + } + if (BIG_HEX_REGEX.test(value)) { + return parseBohNumber(value.slice(0, -1), config.hexadecimalNumber); } return function (number) { return Number.isNaN(number) ? 0 : safeZero(number); @@ -309,14 +354,26 @@ function defaultConfig() { if (NUMBER_REGEX.test(value)) { return numberAsBigInt(parseNumber(value)); } - if (NUM_BOH_REGEX.test(value)) { - return numberAsBigInt(parseBohNumber(value)); + if (NUM_BIN_REGEX.test(value)) { + return parseBohBigInt("".concat(value, "n"), config.binaryBigInt); + } + if (NUM_OCT_REGEX.test(value)) { + return parseBohBigInt("".concat(value, "n"), config.octalBigInt); + } + if (NUM_HEX_REGEX.test(value)) { + return parseBohBigInt("".concat(value, "n"), config.hexadecimalBigInt); } if (BIGINT_REGEX.test(value)) { return parseBigInt(value); } - if (BIG_BOH_REGEX.test(value)) { - return parseBohBigInt(value); + if (BIG_BIN_REGEX.test(value)) { + return parseBohBigInt(value, config.binaryBigInt); + } + if (BIG_OCT_REGEX.test(value)) { + return parseBohBigInt(value, config.octalBigInt); + } + if (BIG_HEX_REGEX.test(value)) { + return parseBohBigInt(value, config.hexadecimalBigInt); } return function (number) { return Number.isNaN(number) ? 0n : numberAsBigInt(safeZero(number)); @@ -376,6 +433,24 @@ function mergeConfig(config) { if ('ignoreProcessEnv' in config) { mergingConfig.ignoreProcessEnv = config.ignoreProcessEnv; } + if ('binaryNumber' in config) { + mergingConfig.binaryNumber = config.binaryNumber; + } + if ('octalNumber' in config) { + mergingConfig.octalNumber = config.octalNumber; + } + if ('hexadecimalNumber' in config) { + mergingConfig.hexadecimalNumber = config.hexadecimalNumber; + } + if ('binaryBigInt' in config) { + mergingConfig.binaryBigInt = config.binaryBigInt; + } + if ('octalBigInt' in config) { + mergingConfig.octalBigInt = config.octalBigInt; + } + if ('hexadecimalBigInt' in config) { + mergingConfig.hexadecimalBigInt = config.hexadecimalBigInt; + } if ('prevents' in config) { mergingConfig.prevents = config.prevents; } diff --git a/src/index.js b/src/index.js index 066e3de..c0a1eab 100644 --- a/src/index.js +++ b/src/index.js @@ -3,9 +3,13 @@ */ const NUMBER_REGEX = /^[+-]?(\d+(\.(\d*)?)?|\.\d+)([eE][+-]?\d+)?$/ -const NUM_BOH_REGEX = /^[+-]?0([bB][01]+|[oO][0-8]+|[xX][0-9a-fA-F]+)$/ +const NUM_BIN_REGEX = /^[+-]?0[bB][01]+$/ +const NUM_OCT_REGEX = /^[+-]?0[oO][0-8]+$/ +const NUM_HEX_REGEX = /^[+-]?0[xX][0-9a-fA-F]+$/ const BIGINT_REGEX = /^[+-]?\d+n$/ -const BIG_BOH_REGEX = /^[+-]?0([bB][01]+|[oO][0-8]+|[xX][0-9a-fA-F]+)n$/ +const BIG_BIN_REGEX = /^[+-]?0[bB][01]+n$/ +const BIG_OCT_REGEX = /^[+-]?0[oO][0-8]+n$/ +const BIG_HEX_REGEX = /^[+-]?0[xX][0-9a-fA-F]+n$/ const SYMBOL_REGEX = /^Symbol\(.*\)$/ const ARRAY_REGEX = /^\[.*]$/ const ARRAY_EMPTY_REGEX = /^\[\s*]$/ @@ -71,9 +75,13 @@ function parseNumber(str) { /** * * @param {string} str - * @returns {number} + * @param {boolean} parsed + * @returns {number|string} */ -function parseBohNumber(str) { +function parseBohNumber(str, parsed = true) { + if (!parsed) { + return str + } switch (str[0]) { case '+': return Number(str.substring(1)) @@ -96,9 +104,13 @@ function parseBigInt(str) { /** * * @param {string} str - * @returns {bigint} + * @param {boolean} parsed + * @returns {bigint|string} */ -function parseBohBigInt(str) { +function parseBohBigInt(str, parsed = true) { + if (!parsed) { + return str + } switch (str[0]) { case '+': return BigInt(str.slice(1, -1)) @@ -130,18 +142,19 @@ function parseSymbol(str) { /** * * @param {string|*} value - * @param {object} valueTable - * @param {boolean} fromDotEnv + * @param {object} config * @returns {null|undefined|boolean|number|bigint|string|symbol|array|object} */ -function restoreValue(value, valueTable, fromDotEnv) { +function restoreValue(value, config) { if (!(typeof value == 'string' || value instanceof String)) { return value } - if (fromDotEnv) { + if (config.fromDotEnv) { value = unescapeValue(value) } const trimmed = value.trim() + // defined values + const valueTable = config._cache.valueTables.forAutoForced if (trimmed in valueTable) { return valueTable[trimmed] } @@ -149,15 +162,27 @@ function restoreValue(value, valueTable, fromDotEnv) { if (NUMBER_REGEX.test(trimmed)) { return parseNumber(trimmed) } - if (NUM_BOH_REGEX.test(trimmed)) { - return parseBohNumber(trimmed) + if (NUM_BIN_REGEX.test(trimmed)) { + return parseBohNumber(trimmed, config.binaryNumber) + } + if (NUM_OCT_REGEX.test(trimmed)) { + return parseBohNumber(trimmed, config.octalNumber) + } + if (NUM_HEX_REGEX.test(trimmed)) { + return parseBohNumber(trimmed, config.hexadecimalNumber) } // BigInt if (BIGINT_REGEX.test(trimmed)) { return parseBigInt(trimmed) } - if (BIG_BOH_REGEX.test(trimmed)) { - return parseBohBigInt(trimmed) + if (BIG_BIN_REGEX.test(trimmed)) { + return parseBohBigInt(trimmed, config.binaryBigInt) + } + if (BIG_OCT_REGEX.test(trimmed)) { + return parseBohBigInt(trimmed, config.octalBigInt) + } + if (BIG_HEX_REGEX.test(trimmed)) { + return parseBohBigInt(trimmed, config.hexadecimalBigInt) } // Symbol if (SYMBOL_REGEX.test(trimmed)) { @@ -240,13 +265,23 @@ function flattenValue(value) { function defaultConfig() { return { parsed: {}, + fromDotEnv: true, + ignoreProcessEnv: false, + + binaryNumber: true, + octalNumber: true, + hexadecimalNumber: true, + binaryBigInt: true, + octalBigInt: true, + hexadecimalBigInt: true, + prevents: [], specs: {}, methods: { auto(value, name, config) { - value = restoreValue(value, config._cache.valueTables.forAutoForced, config.fromDotEnv) + value = restoreValue(value, config) if (typeof value === 'string') { const lTrimmed = value.replace(/^\s+/, '') const findPossibleMethod = methods => methods.find(method => lTrimmed.startsWith(`${method}:`)) @@ -285,13 +320,17 @@ function defaultConfig() { if (NUMBER_REGEX.test(value)) { return parseNumber(value) !== 0 } - if (NUM_BOH_REGEX.test(value)) { + if (NUM_BIN_REGEX.test(value) + || NUM_OCT_REGEX.test(value) + || NUM_HEX_REGEX.test(value)) { return parseBohNumber(value) !== 0 } if (BIGINT_REGEX.test(value)) { return parseBigInt(value) !== 0n } - if (BIG_BOH_REGEX.test(value)) { + if (BIG_BIN_REGEX.test(value) + || BIG_OCT_REGEX.test(value) + || BIG_HEX_REGEX.test(value)) { return parseBohBigInt(value) !== 0n } return true @@ -308,14 +347,26 @@ function defaultConfig() { if (NUMBER_REGEX.test(value)) { return parseNumber(value) } - if (NUM_BOH_REGEX.test(value)) { - return parseBohNumber(value) + if (NUM_BIN_REGEX.test(value)) { + return parseBohNumber(value, config.binaryNumber) + } + if (NUM_OCT_REGEX.test(value)) { + return parseBohNumber(value, config.octalNumber) + } + if (NUM_HEX_REGEX.test(value)) { + return parseBohNumber(value, config.hexadecimalNumber) } if (BIGINT_REGEX.test(value)) { return parseNumber(value.slice(0, -1)) } - if (BIG_BOH_REGEX.test(value)) { - return parseBohNumber(value.slice(0, -1)) + if (BIG_BIN_REGEX.test(value)) { + return parseBohNumber(value.slice(0, -1), config.binaryNumber) + } + if (BIG_OCT_REGEX.test(value)) { + return parseBohNumber(value.slice(0, -1), config.octalNumber) + } + if (BIG_HEX_REGEX.test(value)) { + return parseBohNumber(value.slice(0, -1), config.hexadecimalNumber) } return (number => Number.isNaN(number) ? 0 : safeZero(number))(Number.parseFloat(value)) }, @@ -331,14 +382,26 @@ function defaultConfig() { if (NUMBER_REGEX.test(value)) { return numberAsBigInt(parseNumber(value)) } - if (NUM_BOH_REGEX.test(value)) { - return numberAsBigInt(parseBohNumber(value)) + if (NUM_BIN_REGEX.test(value)) { + return parseBohBigInt(`${value}n`, config.binaryBigInt) + } + if (NUM_OCT_REGEX.test(value)) { + return parseBohBigInt(`${value}n`, config.octalBigInt) + } + if (NUM_HEX_REGEX.test(value)) { + return parseBohBigInt(`${value}n`, config.hexadecimalBigInt) } if (BIGINT_REGEX.test(value)) { return parseBigInt(value) } - if (BIG_BOH_REGEX.test(value)) { - return parseBohBigInt(value) + if (BIG_BIN_REGEX.test(value)) { + return parseBohBigInt(value, config.binaryBigInt) + } + if (BIG_OCT_REGEX.test(value)) { + return parseBohBigInt(value, config.octalBigInt) + } + if (BIG_HEX_REGEX.test(value)) { + return parseBohBigInt(value, config.hexadecimalBigInt) } return (number => Number.isNaN(number) ? 0n : numberAsBigInt(safeZero(number)))(Number.parseFloat(value)) }, @@ -407,6 +470,24 @@ function mergeConfig(config) { if ('ignoreProcessEnv' in config) { mergingConfig.ignoreProcessEnv = config.ignoreProcessEnv } + if ('binaryNumber' in config) { + mergingConfig.binaryNumber = config.binaryNumber + } + if ('octalNumber' in config) { + mergingConfig.octalNumber = config.octalNumber + } + if ('hexadecimalNumber' in config) { + mergingConfig.hexadecimalNumber = config.hexadecimalNumber + } + if ('binaryBigInt' in config) { + mergingConfig.binaryBigInt = config.binaryBigInt + } + if ('octalBigInt' in config) { + mergingConfig.octalBigInt = config.octalBigInt + } + if ('hexadecimalBigInt' in config) { + mergingConfig.hexadecimalBigInt = config.hexadecimalBigInt + } if ('prevents' in config) { mergingConfig.prevents = config.prevents } diff --git a/tests/index.js b/tests/index.js index 41cf347..a272ca8 100644 --- a/tests/index.js +++ b/tests/index.js @@ -2,9 +2,9 @@ import chai from 'chai' import dotenv from 'dotenv' import dotenvExpand from 'dotenv-expand' import dotenvFlow from 'dotenv-flow' -import dotenvConversion from '../src' import fs from 'fs' import mocha from 'mocha' +import dotenvConversion from '../src' // const before = mocha.after // const beforeEach = mocha.beforeEach @@ -35,6 +35,12 @@ describe('dotenv-conversion', function () { const expectedParsed = {} const expectedFromDotEnv = true const expectedIgnoreProcessEnv = false + const expectedBinaryNumber = true + const expectedOctalNumber = true + const expectedHexadecimalNumber = true + const expectedBinaryBigInt = true + const expectedOctalBigInt = true + const expectedHexadecimalBigInt = true const expectedPrevents = [] const expectedSpecs = {} const expectedMethods = [ @@ -64,6 +70,12 @@ describe('dotenv-conversion', function () { expect(dotenvConversionConfig).to.have.property('parsed') expect(dotenvConversionConfig).to.have.property('fromDotEnv') expect(dotenvConversionConfig).to.have.property('ignoreProcessEnv') + expect(dotenvConversionConfig).to.have.property('binaryNumber') + expect(dotenvConversionConfig).to.have.property('octalNumber') + expect(dotenvConversionConfig).to.have.property('hexadecimalNumber') + expect(dotenvConversionConfig).to.have.property('binaryBigInt') + expect(dotenvConversionConfig).to.have.property('octalBigInt') + expect(dotenvConversionConfig).to.have.property('hexadecimalBigInt') expect(dotenvConversionConfig).to.have.property('prevents') expect(dotenvConversionConfig).to.have.property('specs') expect(dotenvConversionConfig).to.have.property('methods') @@ -72,6 +84,12 @@ describe('dotenv-conversion', function () { expect(dotenvConversionConfig.parsed).to.deep.equal(expectedParsed) expect(dotenvConversionConfig.fromDotEnv).to.equal(expectedFromDotEnv) expect(dotenvConversionConfig.ignoreProcessEnv).to.equal(expectedIgnoreProcessEnv) + expect(dotenvConversionConfig.binaryNumber).to.equal(expectedBinaryNumber) + expect(dotenvConversionConfig.octalNumber).to.equal(expectedOctalNumber) + expect(dotenvConversionConfig.hexadecimalNumber).to.equal(expectedHexadecimalNumber) + expect(dotenvConversionConfig.binaryBigInt).to.equal(expectedBinaryBigInt) + expect(dotenvConversionConfig.octalBigInt).to.equal(expectedOctalBigInt) + expect(dotenvConversionConfig.hexadecimalBigInt).to.equal(expectedHexadecimalBigInt) expect(dotenvConversionConfig.prevents).to.deep.equal(expectedPrevents) expect(dotenvConversionConfig.specs).to.deep.equal(expectedSpecs) expect(Object.keys(dotenvConversionConfig.methods)).to.deep.equal(expectedMethods) @@ -90,6 +108,12 @@ describe('dotenv-conversion', function () { }, fromDotEnv: false, ignoreProcessEnv: true, + binaryNumber: false, + octalNumber: false, + hexadecimalNumber: false, + binaryBigInt: false, + octalBigInt: false, + hexadecimalBigInt: false, prevents: ['BASIC'], specs: { BASIC(value) { @@ -122,6 +146,12 @@ describe('dotenv-conversion', function () { } const expectedFromDotEnv = inputConfig.fromDotEnv const expectedIgnoreProcessEnv = inputConfig.ignoreProcessEnv + const expectedBinaryNumber = inputConfig.binaryNumber + const expectedOctalNumber = inputConfig.octalNumber + const expectedHexadecimalNumber = inputConfig.hexadecimalNumber + const expectedBinaryBigInt = inputConfig.binaryBigInt + const expectedOctalBigInt = inputConfig.octalBigInt + const expectedHexadecimalBigInt = inputConfig.hexadecimalBigInt const expectedPrevents = inputConfig.prevents const expectedSpecs = inputConfig.specs const expectedMethods = [ @@ -157,6 +187,12 @@ describe('dotenv-conversion', function () { expect(dotenvConversionConfig).to.have.property('parsed') expect(dotenvConversionConfig).to.have.property('fromDotEnv') expect(dotenvConversionConfig).to.have.property('ignoreProcessEnv') + expect(dotenvConversionConfig).to.have.property('binaryNumber') + expect(dotenvConversionConfig).to.have.property('octalNumber') + expect(dotenvConversionConfig).to.have.property('hexadecimalNumber') + expect(dotenvConversionConfig).to.have.property('binaryBigInt') + expect(dotenvConversionConfig).to.have.property('octalBigInt') + expect(dotenvConversionConfig).to.have.property('hexadecimalBigInt') expect(dotenvConversionConfig).to.have.property('prevents') expect(dotenvConversionConfig).to.have.property('specs') expect(dotenvConversionConfig).to.have.property('methods') @@ -165,6 +201,12 @@ describe('dotenv-conversion', function () { expect(dotenvConversionConfig.parsed).to.deep.equal(expectedParsed) expect(dotenvConversionConfig.fromDotEnv).to.equal(expectedFromDotEnv) expect(dotenvConversionConfig.ignoreProcessEnv).to.equal(expectedIgnoreProcessEnv) + expect(dotenvConversionConfig.binaryNumber).to.equal(expectedBinaryNumber) + expect(dotenvConversionConfig.octalNumber).to.equal(expectedOctalNumber) + expect(dotenvConversionConfig.hexadecimalNumber).to.equal(expectedHexadecimalNumber) + expect(dotenvConversionConfig.binaryBigInt).to.equal(expectedBinaryBigInt) + expect(dotenvConversionConfig.octalBigInt).to.equal(expectedOctalBigInt) + expect(dotenvConversionConfig.hexadecimalBigInt).to.equal(expectedHexadecimalBigInt) expect(dotenvConversionConfig.prevents).to.deep.equal(expectedPrevents) expect(dotenvConversionConfig.specs).to.deep.equal(expectedSpecs) expect(Object.keys(dotenvConversionConfig.methods)).to.deep.equal(expectedMethods) @@ -225,11 +267,11 @@ describe('dotenv-conversion', function () { }) describe('convert:standalone', function () { - function useEnv(env) { - return { + function useEnv(env, options = {}) { + return Object.assign(options, { fromDotEnv: false, parsed: env, - } + }) } it('ignoreProcessEnv:no', function (done) { @@ -1171,6 +1213,87 @@ describe('dotenv-conversion', function () { done() }) + it('method:auto:number:boh>>false', function (done) { + // input + const options = { + binaryNumber: false, + octalNumber: false, + hexadecimalNumber: false, + } + const input = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + } + + // expected output + const expected = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + } + const expectedForEnv = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + } + + // executes + const dotenvConfig = useEnv(input, options) + const dotenvConversionConfig = dotenvConversion.convert(dotenvConfig) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:auto:bigint', function (done) { // input const input = { @@ -1415,6 +1538,87 @@ describe('dotenv-conversion', function () { done() }) + it('method:auto:bigint:boh>>false', function (done) { + // input + const options = { + binaryBigInt: false, + octalBigInt: false, + hexadecimalBigInt: false, + } + const input = { + BIGINT_201: '0b1010n', + BIGINT_202: '+0b1010n', + BIGINT_203: '-0b1010n', + BIGINT_204: '0B1010n', + BIGINT_205: '+0B1010n', + BIGINT_206: '-0B1010n', + BIGINT_211: '0o12n', + BIGINT_212: '+0o12n', + BIGINT_213: '-0o12n', + BIGINT_214: '0O12n', + BIGINT_215: '+0O12n', + BIGINT_216: '-0O12n', + BIGINT_221: '0xan', + BIGINT_222: '+0xan', + BIGINT_223: '-0xan', + BIGINT_224: '0XAn', + BIGINT_225: '+0XAn', + BIGINT_226: '-0XAn', + } + + // expected output + const expected = { + BIGINT_201: '0b1010n', + BIGINT_202: '+0b1010n', + BIGINT_203: '-0b1010n', + BIGINT_204: '0B1010n', + BIGINT_205: '+0B1010n', + BIGINT_206: '-0B1010n', + BIGINT_211: '0o12n', + BIGINT_212: '+0o12n', + BIGINT_213: '-0o12n', + BIGINT_214: '0O12n', + BIGINT_215: '+0O12n', + BIGINT_216: '-0O12n', + BIGINT_221: '0xan', + BIGINT_222: '+0xan', + BIGINT_223: '-0xan', + BIGINT_224: '0XAn', + BIGINT_225: '+0XAn', + BIGINT_226: '-0XAn', + } + const expectedForEnv = { + BIGINT_201: '0b1010n', + BIGINT_202: '+0b1010n', + BIGINT_203: '-0b1010n', + BIGINT_204: '0B1010n', + BIGINT_205: '+0B1010n', + BIGINT_206: '-0B1010n', + BIGINT_211: '0o12n', + BIGINT_212: '+0o12n', + BIGINT_213: '-0o12n', + BIGINT_214: '0O12n', + BIGINT_215: '+0O12n', + BIGINT_216: '-0O12n', + BIGINT_221: '0xan', + BIGINT_222: '+0xan', + BIGINT_223: '-0xan', + BIGINT_224: '0XAn', + BIGINT_225: '+0XAn', + BIGINT_226: '-0XAn', + } + + // executes + const dotenvConfig = useEnv(input, options) + const dotenvConversionConfig = dotenvConversion.convert(dotenvConfig) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:auto:symbol', function (done) { // input const input = { @@ -2147,74 +2351,329 @@ describe('dotenv-conversion', function () { done() }) - it('method:number', function (done) { + it('method:boolean:boh>>false', function (done) { // input + const options = { + binaryNumber: false, + octalNumber: false, + hexadecimalNumber: false, + binaryBigInt: false, + octalBigInt: false, + hexadecimalBigInt: false, + } const input = { - NUMBER_1: 'number:true', - NUMBER_2: 'number:True', - NUMBER_3: 'number:TRUE', - NUMBER_4: 'number:yes', - NUMBER_5: 'number:Yes', - NUMBER_6: 'number:YES', - NUMBER_7: 'number:false', - NUMBER_8: 'number:False', - NUMBER_9: 'number:FALSE', - NUMBER_10: 'number:no', - NUMBER_11: 'number:No', - NUMBER_12: 'number:NO', - NUMBER_13: 'number:null', - NUMBER_14: 'number:Null', - NUMBER_15: 'number:NULL', - NUMBER_16: 'number:undefined', - NUMBER_17: 'number:UNDEFINED', - NUMBER_18: 'number:not', - NUMBER_19: 'number:Not', - NUMBER_20: 'number:NOT', - NUMBER_21: 'number:none', - NUMBER_22: 'number:None', - NUMBER_23: 'number:NONE', - NUMBER_24: 'number:NaN', - NUMBER_25: 'number:Infinity', - NUMBER_26: 'number:+Infinity', - NUMBER_27: 'number:-Infinity', - NUMBER_28: 'number:0', - NUMBER_29: 'number:+0', - NUMBER_30: 'number:-0', - NUMBER_31: 'number:0n', - NUMBER_32: 'number:+0n', - NUMBER_33: 'number:-0n', - NUMBER_34: 'number:1n', - NUMBER_35: 'number:+1n', - NUMBER_36: 'number:-1n', - NUMBER_37: 'number:[]', - NUMBER_38: 'number:{}', - - NUMBER_41: 'number:4.5e1', - NUMBER_42: 'number:+4.5e+1', - NUMBER_43: 'number:-4.5e-1', - NUMBER_44: 'number:4.5e123', - NUMBER_45: 'number:+4.5e+123', - NUMBER_46: 'number:-4.5e-123', - - NUMBER_101: 'number:', - NUMBER_102: 'number:4.5e+123any', - NUMBER_103: 'number:any', - NUMBER_104: ' number: ', - NUMBER_105: ' number: true ', - NUMBER_106: ' number: false ', - NUMBER_107: ' number: 4.5e+123any ', - NUMBER_108: ' number: any ', + BOOLEAN_401: 'boolean:0b1010', + BOOLEAN_402: 'boolean:+0b1010', + BOOLEAN_403: 'boolean:-0b1010', + BOOLEAN_404: 'boolean:0B1010', + BOOLEAN_405: 'boolean:+0B1010', + BOOLEAN_406: 'boolean:-0B1010', + BOOLEAN_411: 'boolean:0o12', + BOOLEAN_412: 'boolean:+0o12', + BOOLEAN_413: 'boolean:-0o12', + BOOLEAN_414: 'boolean:0O12', + BOOLEAN_415: 'boolean:+0O12', + BOOLEAN_416: 'boolean:-0O12', + BOOLEAN_421: 'boolean:0xa', + BOOLEAN_422: 'boolean:+0xa', + BOOLEAN_423: 'boolean:-0xa', + BOOLEAN_424: 'boolean:0XA', + BOOLEAN_425: 'boolean:+0XA', + BOOLEAN_426: 'boolean:-0XA', - NUMBER_201: 'num:', - NUMBER_202: 'num:4.5e+123any', - NUMBER_203: 'num:any', - NUMBER_204: ' num: ', - NUMBER_205: ' num: true ', - NUMBER_206: ' num: false ', - NUMBER_207: ' num: 4.5e+123any ', - NUMBER_208: ' num: any ', + BOOLEAN_501: 'boolean:0b0', + BOOLEAN_502: 'boolean:+0b0', + BOOLEAN_503: 'boolean:-0b0', + BOOLEAN_504: 'boolean:0B0', + BOOLEAN_505: 'boolean:+0B0', + BOOLEAN_506: 'boolean:-0B0', + BOOLEAN_511: 'boolean:0o0', + BOOLEAN_512: 'boolean:+0o0', + BOOLEAN_513: 'boolean:-0o0', + BOOLEAN_514: 'boolean:0O0', + BOOLEAN_515: 'boolean:+0O0', + BOOLEAN_516: 'boolean:-0O0', + BOOLEAN_521: 'boolean:0x0', + BOOLEAN_522: 'boolean:+0x0', + BOOLEAN_523: 'boolean:-0x0', + BOOLEAN_524: 'boolean:0X0', + BOOLEAN_525: 'boolean:+0X0', + BOOLEAN_526: 'boolean:-0X0', - NUMBER_301: 'number:0b1010', + BOOLEAN_601: 'boolean:0b1010n', + BOOLEAN_602: 'boolean:+0b1010n', + BOOLEAN_603: 'boolean:-0b1010n', + BOOLEAN_604: 'boolean:0B1010n', + BOOLEAN_605: 'boolean:+0B1010n', + BOOLEAN_606: 'boolean:-0B1010n', + BOOLEAN_611: 'boolean:0o12n', + BOOLEAN_612: 'boolean:+0o12n', + BOOLEAN_613: 'boolean:-0o12n', + BOOLEAN_614: 'boolean:0O12n', + BOOLEAN_615: 'boolean:+0O12n', + BOOLEAN_616: 'boolean:-0O12n', + BOOLEAN_621: 'boolean:0xan', + BOOLEAN_622: 'boolean:+0xan', + BOOLEAN_623: 'boolean:-0xan', + BOOLEAN_624: 'boolean:0XAn', + BOOLEAN_625: 'boolean:+0XAn', + BOOLEAN_626: 'boolean:-0XAn', + + BOOLEAN_701: 'boolean:0b0n', + BOOLEAN_702: 'boolean:+0b0n', + BOOLEAN_703: 'boolean:-0b0n', + BOOLEAN_704: 'boolean:0B0n', + BOOLEAN_705: 'boolean:+0B0n', + BOOLEAN_706: 'boolean:-0B0n', + BOOLEAN_711: 'boolean:0o0n', + BOOLEAN_712: 'boolean:+0o0n', + BOOLEAN_713: 'boolean:-0o0n', + BOOLEAN_714: 'boolean:0O0n', + BOOLEAN_715: 'boolean:+0O0n', + BOOLEAN_716: 'boolean:-0O0n', + BOOLEAN_721: 'boolean:0x0n', + BOOLEAN_722: 'boolean:+0x0n', + BOOLEAN_723: 'boolean:-0x0n', + BOOLEAN_724: 'boolean:0X0n', + BOOLEAN_725: 'boolean:+0X0n', + BOOLEAN_726: 'boolean:-0X0n', + } + + // expected output + const expected = { + BOOLEAN_401: true, + BOOLEAN_402: true, + BOOLEAN_403: true, + BOOLEAN_404: true, + BOOLEAN_405: true, + BOOLEAN_406: true, + BOOLEAN_411: true, + BOOLEAN_412: true, + BOOLEAN_413: true, + BOOLEAN_414: true, + BOOLEAN_415: true, + BOOLEAN_416: true, + BOOLEAN_421: true, + BOOLEAN_422: true, + BOOLEAN_423: true, + BOOLEAN_424: true, + BOOLEAN_425: true, + BOOLEAN_426: true, + + BOOLEAN_501: false, + BOOLEAN_502: false, + BOOLEAN_503: false, + BOOLEAN_504: false, + BOOLEAN_505: false, + BOOLEAN_506: false, + BOOLEAN_511: false, + BOOLEAN_512: false, + BOOLEAN_513: false, + BOOLEAN_514: false, + BOOLEAN_515: false, + BOOLEAN_516: false, + BOOLEAN_521: false, + BOOLEAN_522: false, + BOOLEAN_523: false, + BOOLEAN_524: false, + BOOLEAN_525: false, + BOOLEAN_526: false, + + BOOLEAN_601: true, + BOOLEAN_602: true, + BOOLEAN_603: true, + BOOLEAN_604: true, + BOOLEAN_605: true, + BOOLEAN_606: true, + BOOLEAN_611: true, + BOOLEAN_612: true, + BOOLEAN_613: true, + BOOLEAN_614: true, + BOOLEAN_615: true, + BOOLEAN_616: true, + BOOLEAN_621: true, + BOOLEAN_622: true, + BOOLEAN_623: true, + BOOLEAN_624: true, + BOOLEAN_625: true, + BOOLEAN_626: true, + + BOOLEAN_701: false, + BOOLEAN_702: false, + BOOLEAN_703: false, + BOOLEAN_704: false, + BOOLEAN_705: false, + BOOLEAN_706: false, + BOOLEAN_711: false, + BOOLEAN_712: false, + BOOLEAN_713: false, + BOOLEAN_714: false, + BOOLEAN_715: false, + BOOLEAN_716: false, + BOOLEAN_721: false, + BOOLEAN_722: false, + BOOLEAN_723: false, + BOOLEAN_724: false, + BOOLEAN_725: false, + BOOLEAN_726: false, + } + const expectedForEnv = { + BOOLEAN_401: 'true', + BOOLEAN_402: 'true', + BOOLEAN_403: 'true', + BOOLEAN_404: 'true', + BOOLEAN_405: 'true', + BOOLEAN_406: 'true', + BOOLEAN_411: 'true', + BOOLEAN_412: 'true', + BOOLEAN_413: 'true', + BOOLEAN_414: 'true', + BOOLEAN_415: 'true', + BOOLEAN_416: 'true', + BOOLEAN_421: 'true', + BOOLEAN_422: 'true', + BOOLEAN_423: 'true', + BOOLEAN_424: 'true', + BOOLEAN_425: 'true', + BOOLEAN_426: 'true', + + BOOLEAN_501: 'false', + BOOLEAN_502: 'false', + BOOLEAN_503: 'false', + BOOLEAN_504: 'false', + BOOLEAN_505: 'false', + BOOLEAN_506: 'false', + BOOLEAN_511: 'false', + BOOLEAN_512: 'false', + BOOLEAN_513: 'false', + BOOLEAN_514: 'false', + BOOLEAN_515: 'false', + BOOLEAN_516: 'false', + BOOLEAN_521: 'false', + BOOLEAN_522: 'false', + BOOLEAN_523: 'false', + BOOLEAN_524: 'false', + BOOLEAN_525: 'false', + BOOLEAN_526: 'false', + + BOOLEAN_601: 'true', + BOOLEAN_602: 'true', + BOOLEAN_603: 'true', + BOOLEAN_604: 'true', + BOOLEAN_605: 'true', + BOOLEAN_606: 'true', + BOOLEAN_611: 'true', + BOOLEAN_612: 'true', + BOOLEAN_613: 'true', + BOOLEAN_614: 'true', + BOOLEAN_615: 'true', + BOOLEAN_616: 'true', + BOOLEAN_621: 'true', + BOOLEAN_622: 'true', + BOOLEAN_623: 'true', + BOOLEAN_624: 'true', + BOOLEAN_625: 'true', + BOOLEAN_626: 'true', + + BOOLEAN_701: 'false', + BOOLEAN_702: 'false', + BOOLEAN_703: 'false', + BOOLEAN_704: 'false', + BOOLEAN_705: 'false', + BOOLEAN_706: 'false', + BOOLEAN_711: 'false', + BOOLEAN_712: 'false', + BOOLEAN_713: 'false', + BOOLEAN_714: 'false', + BOOLEAN_715: 'false', + BOOLEAN_716: 'false', + BOOLEAN_721: 'false', + BOOLEAN_722: 'false', + BOOLEAN_723: 'false', + BOOLEAN_724: 'false', + BOOLEAN_725: 'false', + BOOLEAN_726: 'false', + } + + // executes + const dotenvConfig = useEnv(input, options) + const dotenvConversionConfig = dotenvConversion.convert(dotenvConfig) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + + it('method:number', function (done) { + // input + const input = { + NUMBER_1: 'number:true', + NUMBER_2: 'number:True', + NUMBER_3: 'number:TRUE', + NUMBER_4: 'number:yes', + NUMBER_5: 'number:Yes', + NUMBER_6: 'number:YES', + NUMBER_7: 'number:false', + NUMBER_8: 'number:False', + NUMBER_9: 'number:FALSE', + NUMBER_10: 'number:no', + NUMBER_11: 'number:No', + NUMBER_12: 'number:NO', + NUMBER_13: 'number:null', + NUMBER_14: 'number:Null', + NUMBER_15: 'number:NULL', + NUMBER_16: 'number:undefined', + NUMBER_17: 'number:UNDEFINED', + NUMBER_18: 'number:not', + NUMBER_19: 'number:Not', + NUMBER_20: 'number:NOT', + NUMBER_21: 'number:none', + NUMBER_22: 'number:None', + NUMBER_23: 'number:NONE', + NUMBER_24: 'number:NaN', + NUMBER_25: 'number:Infinity', + NUMBER_26: 'number:+Infinity', + NUMBER_27: 'number:-Infinity', + NUMBER_28: 'number:0', + NUMBER_29: 'number:+0', + NUMBER_30: 'number:-0', + NUMBER_31: 'number:0n', + NUMBER_32: 'number:+0n', + NUMBER_33: 'number:-0n', + NUMBER_34: 'number:1n', + NUMBER_35: 'number:+1n', + NUMBER_36: 'number:-1n', + NUMBER_37: 'number:[]', + NUMBER_38: 'number:{}', + + NUMBER_41: 'number:4.5e1', + NUMBER_42: 'number:+4.5e+1', + NUMBER_43: 'number:-4.5e-1', + NUMBER_44: 'number:4.5e123', + NUMBER_45: 'number:+4.5e+123', + NUMBER_46: 'number:-4.5e-123', + + NUMBER_101: 'number:', + NUMBER_102: 'number:4.5e+123any', + NUMBER_103: 'number:any', + NUMBER_104: ' number: ', + NUMBER_105: ' number: true ', + NUMBER_106: ' number: false ', + NUMBER_107: ' number: 4.5e+123any ', + NUMBER_108: ' number: any ', + + NUMBER_201: 'num:', + NUMBER_202: 'num:4.5e+123any', + NUMBER_203: 'num:any', + NUMBER_204: ' num: ', + NUMBER_205: ' num: true ', + NUMBER_206: ' num: false ', + NUMBER_207: ' num: 4.5e+123any ', + NUMBER_208: ' num: any ', + + NUMBER_301: 'number:0b1010', NUMBER_302: 'number:+0b1010', NUMBER_303: 'number:-0b1010', NUMBER_304: 'number:0B1010', @@ -2553,6 +3012,144 @@ describe('dotenv-conversion', function () { done() }) + it('method:number:boh>>false', function (done) { + // input + const options = { + binaryNumber: false, + octalNumber: false, + hexadecimalNumber: false, + } + const input = { + NUMBER_301: 'number:0b1010', + NUMBER_302: 'number:+0b1010', + NUMBER_303: 'number:-0b1010', + NUMBER_304: 'number:0B1010', + NUMBER_305: 'number:+0B1010', + NUMBER_306: 'number:-0B1010', + NUMBER_311: 'number:0o12', + NUMBER_312: 'number:+0o12', + NUMBER_313: 'number:-0o12', + NUMBER_314: 'number:0O12', + NUMBER_315: 'number:+0O12', + NUMBER_316: 'number:-0O12', + NUMBER_321: 'number:0xa', + NUMBER_322: 'number:+0xa', + NUMBER_323: 'number:-0xa', + NUMBER_324: 'number:0XA', + NUMBER_325: 'number:+0XA', + NUMBER_326: 'number:-0XA', + + NUMBER_401: 'number:0b1010n', + NUMBER_402: 'number:+0b1010n', + NUMBER_403: 'number:-0b1010n', + NUMBER_404: 'number:0B1010n', + NUMBER_405: 'number:+0B1010n', + NUMBER_406: 'number:-0B1010n', + NUMBER_411: 'number:0o12n', + NUMBER_412: 'number:+0o12n', + NUMBER_413: 'number:-0o12n', + NUMBER_414: 'number:0O12n', + NUMBER_415: 'number:+0O12n', + NUMBER_416: 'number:-0O12n', + NUMBER_421: 'number:0xan', + NUMBER_422: 'number:+0xan', + NUMBER_423: 'number:-0xan', + NUMBER_424: 'number:0XAn', + NUMBER_425: 'number:+0XAn', + NUMBER_426: 'number:-0XAn', + } + + // expected output + const expected = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + + NUMBER_401: '0b1010', + NUMBER_402: '+0b1010', + NUMBER_403: '-0b1010', + NUMBER_404: '0B1010', + NUMBER_405: '+0B1010', + NUMBER_406: '-0B1010', + NUMBER_411: '0o12', + NUMBER_412: '+0o12', + NUMBER_413: '-0o12', + NUMBER_414: '0O12', + NUMBER_415: '+0O12', + NUMBER_416: '-0O12', + NUMBER_421: '0xa', + NUMBER_422: '+0xa', + NUMBER_423: '-0xa', + NUMBER_424: '0XA', + NUMBER_425: '+0XA', + NUMBER_426: '-0XA', + } + const expectedForEnv = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + + NUMBER_401: '0b1010', + NUMBER_402: '+0b1010', + NUMBER_403: '-0b1010', + NUMBER_404: '0B1010', + NUMBER_405: '+0B1010', + NUMBER_406: '-0B1010', + NUMBER_411: '0o12', + NUMBER_412: '+0o12', + NUMBER_413: '-0o12', + NUMBER_414: '0O12', + NUMBER_415: '+0O12', + NUMBER_416: '-0O12', + NUMBER_421: '0xa', + NUMBER_422: '+0xa', + NUMBER_423: '-0xa', + NUMBER_424: '0XA', + NUMBER_425: '+0XA', + NUMBER_426: '-0XA', + } + + // executes + const dotenvConfig = useEnv(input, options) + const dotenvConversionConfig = dotenvConversion.convert(dotenvConfig) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:bigint', function (done) { // input const input = { @@ -3019,6 +3616,144 @@ describe('dotenv-conversion', function () { done() }) + it('method:bigint:bod>>false', function (done) { + // input + const options = { + binaryBigInt: false, + octalBigInt: false, + hexadecimalBigInt: false, + } + const input = { + BIGINT_301: 'bigint:0b1010n', + BIGINT_302: 'bigint:+0b1010n', + BIGINT_303: 'bigint:-0b1010n', + BIGINT_304: 'bigint:0B1010n', + BIGINT_305: 'bigint:+0B1010n', + BIGINT_306: 'bigint:-0B1010n', + BIGINT_311: 'bigint:0o12n', + BIGINT_312: 'bigint:+0o12n', + BIGINT_313: 'bigint:-0o12n', + BIGINT_314: 'bigint:0O12n', + BIGINT_315: 'bigint:+0O12n', + BIGINT_316: 'bigint:-0O12n', + BIGINT_321: 'bigint:0xan', + BIGINT_322: 'bigint:+0xan', + BIGINT_323: 'bigint:-0xan', + BIGINT_324: 'bigint:0XAn', + BIGINT_325: 'bigint:+0XAn', + BIGINT_326: 'bigint:-0XAn', + + BIGINT_401: 'bigint:0b1010', + BIGINT_402: 'bigint:+0b1010', + BIGINT_403: 'bigint:-0b1010', + BIGINT_404: 'bigint:0B1010', + BIGINT_405: 'bigint:+0B1010', + BIGINT_406: 'bigint:-0B1010', + BIGINT_411: 'bigint:0o12', + BIGINT_412: 'bigint:+0o12', + BIGINT_413: 'bigint:-0o12', + BIGINT_414: 'bigint:0O12', + BIGINT_415: 'bigint:+0O12', + BIGINT_416: 'bigint:-0O12', + BIGINT_421: 'bigint:0xa', + BIGINT_422: 'bigint:+0xa', + BIGINT_423: 'bigint:-0xa', + BIGINT_424: 'bigint:0XA', + BIGINT_425: 'bigint:+0XA', + BIGINT_426: 'bigint:-0XA', + } + + // expected output + const expected = { + BIGINT_301: '0b1010n', + BIGINT_302: '+0b1010n', + BIGINT_303: '-0b1010n', + BIGINT_304: '0B1010n', + BIGINT_305: '+0B1010n', + BIGINT_306: '-0B1010n', + BIGINT_311: '0o12n', + BIGINT_312: '+0o12n', + BIGINT_313: '-0o12n', + BIGINT_314: '0O12n', + BIGINT_315: '+0O12n', + BIGINT_316: '-0O12n', + BIGINT_321: '0xan', + BIGINT_322: '+0xan', + BIGINT_323: '-0xan', + BIGINT_324: '0XAn', + BIGINT_325: '+0XAn', + BIGINT_326: '-0XAn', + + BIGINT_401: '0b1010n', + BIGINT_402: '+0b1010n', + BIGINT_403: '-0b1010n', + BIGINT_404: '0B1010n', + BIGINT_405: '+0B1010n', + BIGINT_406: '-0B1010n', + BIGINT_411: '0o12n', + BIGINT_412: '+0o12n', + BIGINT_413: '-0o12n', + BIGINT_414: '0O12n', + BIGINT_415: '+0O12n', + BIGINT_416: '-0O12n', + BIGINT_421: '0xan', + BIGINT_422: '+0xan', + BIGINT_423: '-0xan', + BIGINT_424: '0XAn', + BIGINT_425: '+0XAn', + BIGINT_426: '-0XAn', + } + const expectedForEnv = { + BIGINT_301: '0b1010n', + BIGINT_302: '+0b1010n', + BIGINT_303: '-0b1010n', + BIGINT_304: '0B1010n', + BIGINT_305: '+0B1010n', + BIGINT_306: '-0B1010n', + BIGINT_311: '0o12n', + BIGINT_312: '+0o12n', + BIGINT_313: '-0o12n', + BIGINT_314: '0O12n', + BIGINT_315: '+0O12n', + BIGINT_316: '-0O12n', + BIGINT_321: '0xan', + BIGINT_322: '+0xan', + BIGINT_323: '-0xan', + BIGINT_324: '0XAn', + BIGINT_325: '+0XAn', + BIGINT_326: '-0XAn', + + BIGINT_401: '0b1010n', + BIGINT_402: '+0b1010n', + BIGINT_403: '-0b1010n', + BIGINT_404: '0B1010n', + BIGINT_405: '+0B1010n', + BIGINT_406: '-0B1010n', + BIGINT_411: '0o12n', + BIGINT_412: '+0o12n', + BIGINT_413: '-0o12n', + BIGINT_414: '0O12n', + BIGINT_415: '+0O12n', + BIGINT_416: '-0O12n', + BIGINT_421: '0xan', + BIGINT_422: '+0xan', + BIGINT_423: '-0xan', + BIGINT_424: '0XAn', + BIGINT_425: '+0XAn', + BIGINT_426: '-0XAn', + } + + // executes + const dotenvConfig = useEnv(input, options) + const dotenvConversionConfig = dotenvConversion.convert(dotenvConfig) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:string', function (done) { // input const input = { @@ -4373,6 +5108,68 @@ describe('dotenv-conversion', function () { done() }) + it('method:auto:number:boh>>false', function (done) { + // input + const options = { + binaryNumber: false, + octalNumber: false, + hexadecimalNumber: false, + } + const input = 'method.auto.number.boh.false' + + // expected output + const expected = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + } + const expectedForEnv = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + } + + // executes + const dotenvConfig = useEnv(input) + const dotenvConversionConfig = dotenvConversion.convert(Object.assign(options, dotenvConfig)) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:auto:bigint', function (done) { // input const input = 'method.auto.bigint' @@ -4533,7 +5330,69 @@ describe('dotenv-conversion', function () { // executes const dotenvConfig = useEnv(input) - const dotenvConversionConfig = dotenvConversion.convert(dotenvConfig) + const dotenvConversionConfig = dotenvConversion.convert(dotenvConfig) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + + it('method:auto:bigint:boh>>false', function (done) { + // input + const options = { + binaryBigInt: false, + octalBigInt: false, + hexadecimalBigInt: false, + } + const input = 'method.auto.bigint.boh.false' + + // expected output + const expected = { + BIGINT_201: '0b1010n', + BIGINT_202: '+0b1010n', + BIGINT_203: '-0b1010n', + BIGINT_204: '0B1010n', + BIGINT_205: '+0B1010n', + BIGINT_206: '-0B1010n', + BIGINT_211: '0o12n', + BIGINT_212: '+0o12n', + BIGINT_213: '-0o12n', + BIGINT_214: '0O12n', + BIGINT_215: '+0O12n', + BIGINT_216: '-0O12n', + BIGINT_221: '0xan', + BIGINT_222: '+0xan', + BIGINT_223: '-0xan', + BIGINT_224: '0XAn', + BIGINT_225: '+0XAn', + BIGINT_226: '-0XAn', + } + const expectedForEnv = { + BIGINT_201: '0b1010n', + BIGINT_202: '+0b1010n', + BIGINT_203: '-0b1010n', + BIGINT_204: '0B1010n', + BIGINT_205: '+0B1010n', + BIGINT_206: '-0B1010n', + BIGINT_211: '0o12n', + BIGINT_212: '+0o12n', + BIGINT_213: '-0o12n', + BIGINT_214: '0O12n', + BIGINT_215: '+0O12n', + BIGINT_216: '-0O12n', + BIGINT_221: '0xan', + BIGINT_222: '+0xan', + BIGINT_223: '-0xan', + BIGINT_224: '0XAn', + BIGINT_225: '+0XAn', + BIGINT_226: '-0XAn', + } + + // executes + const dotenvConfig = useEnv(input) + const dotenvConversionConfig = dotenvConversion.convert(Object.assign(options, dotenvConfig)) // asserts expect(dotenvConversionConfig.parsed).to.deep.equal(expected) @@ -5061,6 +5920,185 @@ describe('dotenv-conversion', function () { done() }) + it('method:boolean:boh>>false', function (done) { + // input + const options = { + binaryNumber: false, + octalNumber: false, + hexadecimalNumber: false, + binaryBigInt: false, + octalBigInt: false, + hexadecimalBigInt: false, + } + const input = 'method.boolean.boh.false' + + // expected output + const expected = { + BOOLEAN_401: true, + BOOLEAN_402: true, + BOOLEAN_403: true, + BOOLEAN_404: true, + BOOLEAN_405: true, + BOOLEAN_406: true, + BOOLEAN_411: true, + BOOLEAN_412: true, + BOOLEAN_413: true, + BOOLEAN_414: true, + BOOLEAN_415: true, + BOOLEAN_416: true, + BOOLEAN_421: true, + BOOLEAN_422: true, + BOOLEAN_423: true, + BOOLEAN_424: true, + BOOLEAN_425: true, + BOOLEAN_426: true, + + BOOLEAN_501: false, + BOOLEAN_502: false, + BOOLEAN_503: false, + BOOLEAN_504: false, + BOOLEAN_505: false, + BOOLEAN_506: false, + BOOLEAN_511: false, + BOOLEAN_512: false, + BOOLEAN_513: false, + BOOLEAN_514: false, + BOOLEAN_515: false, + BOOLEAN_516: false, + BOOLEAN_521: false, + BOOLEAN_522: false, + BOOLEAN_523: false, + BOOLEAN_524: false, + BOOLEAN_525: false, + BOOLEAN_526: false, + + BOOLEAN_601: true, + BOOLEAN_602: true, + BOOLEAN_603: true, + BOOLEAN_604: true, + BOOLEAN_605: true, + BOOLEAN_606: true, + BOOLEAN_611: true, + BOOLEAN_612: true, + BOOLEAN_613: true, + BOOLEAN_614: true, + BOOLEAN_615: true, + BOOLEAN_616: true, + BOOLEAN_621: true, + BOOLEAN_622: true, + BOOLEAN_623: true, + BOOLEAN_624: true, + BOOLEAN_625: true, + BOOLEAN_626: true, + + BOOLEAN_701: false, + BOOLEAN_702: false, + BOOLEAN_703: false, + BOOLEAN_704: false, + BOOLEAN_705: false, + BOOLEAN_706: false, + BOOLEAN_711: false, + BOOLEAN_712: false, + BOOLEAN_713: false, + BOOLEAN_714: false, + BOOLEAN_715: false, + BOOLEAN_716: false, + BOOLEAN_721: false, + BOOLEAN_722: false, + BOOLEAN_723: false, + BOOLEAN_724: false, + BOOLEAN_725: false, + BOOLEAN_726: false, + } + const expectedForEnv = { + BOOLEAN_401: 'true', + BOOLEAN_402: 'true', + BOOLEAN_403: 'true', + BOOLEAN_404: 'true', + BOOLEAN_405: 'true', + BOOLEAN_406: 'true', + BOOLEAN_411: 'true', + BOOLEAN_412: 'true', + BOOLEAN_413: 'true', + BOOLEAN_414: 'true', + BOOLEAN_415: 'true', + BOOLEAN_416: 'true', + BOOLEAN_421: 'true', + BOOLEAN_422: 'true', + BOOLEAN_423: 'true', + BOOLEAN_424: 'true', + BOOLEAN_425: 'true', + BOOLEAN_426: 'true', + + BOOLEAN_501: 'false', + BOOLEAN_502: 'false', + BOOLEAN_503: 'false', + BOOLEAN_504: 'false', + BOOLEAN_505: 'false', + BOOLEAN_506: 'false', + BOOLEAN_511: 'false', + BOOLEAN_512: 'false', + BOOLEAN_513: 'false', + BOOLEAN_514: 'false', + BOOLEAN_515: 'false', + BOOLEAN_516: 'false', + BOOLEAN_521: 'false', + BOOLEAN_522: 'false', + BOOLEAN_523: 'false', + BOOLEAN_524: 'false', + BOOLEAN_525: 'false', + BOOLEAN_526: 'false', + + BOOLEAN_601: 'true', + BOOLEAN_602: 'true', + BOOLEAN_603: 'true', + BOOLEAN_604: 'true', + BOOLEAN_605: 'true', + BOOLEAN_606: 'true', + BOOLEAN_611: 'true', + BOOLEAN_612: 'true', + BOOLEAN_613: 'true', + BOOLEAN_614: 'true', + BOOLEAN_615: 'true', + BOOLEAN_616: 'true', + BOOLEAN_621: 'true', + BOOLEAN_622: 'true', + BOOLEAN_623: 'true', + BOOLEAN_624: 'true', + BOOLEAN_625: 'true', + BOOLEAN_626: 'true', + + BOOLEAN_701: 'false', + BOOLEAN_702: 'false', + BOOLEAN_703: 'false', + BOOLEAN_704: 'false', + BOOLEAN_705: 'false', + BOOLEAN_706: 'false', + BOOLEAN_711: 'false', + BOOLEAN_712: 'false', + BOOLEAN_713: 'false', + BOOLEAN_714: 'false', + BOOLEAN_715: 'false', + BOOLEAN_716: 'false', + BOOLEAN_721: 'false', + BOOLEAN_722: 'false', + BOOLEAN_723: 'false', + BOOLEAN_724: 'false', + BOOLEAN_725: 'false', + BOOLEAN_726: 'false', + } + + // executes + const dotenvConfig = useEnv(input, options) + const dotenvConversionConfig = dotenvConversion.convert(Object.assign(options, dotenvConfig)) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:number', function (done) { // input const input = 'method.number' @@ -5338,6 +6376,106 @@ describe('dotenv-conversion', function () { done() }) + it('method:number:boh>>false', function (done) { + // input + const options = { + binaryNumber: false, + octalNumber: false, + hexadecimalNumber: false, + } + const input = 'method.number.boh.false' + + // expected output + const expected = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + + NUMBER_401: '0b1010', + NUMBER_402: '+0b1010', + NUMBER_403: '-0b1010', + NUMBER_404: '0B1010', + NUMBER_405: '+0B1010', + NUMBER_406: '-0B1010', + NUMBER_411: '0o12', + NUMBER_412: '+0o12', + NUMBER_413: '-0o12', + NUMBER_414: '0O12', + NUMBER_415: '+0O12', + NUMBER_416: '-0O12', + NUMBER_421: '0xa', + NUMBER_422: '+0xa', + NUMBER_423: '-0xa', + NUMBER_424: '0XA', + NUMBER_425: '+0XA', + NUMBER_426: '-0XA', + } + const expectedForEnv = { + NUMBER_301: '0b1010', + NUMBER_302: '+0b1010', + NUMBER_303: '-0b1010', + NUMBER_304: '0B1010', + NUMBER_305: '+0B1010', + NUMBER_306: '-0B1010', + NUMBER_311: '0o12', + NUMBER_312: '+0o12', + NUMBER_313: '-0o12', + NUMBER_314: '0O12', + NUMBER_315: '+0O12', + NUMBER_316: '-0O12', + NUMBER_321: '0xa', + NUMBER_322: '+0xa', + NUMBER_323: '-0xa', + NUMBER_324: '0XA', + NUMBER_325: '+0XA', + NUMBER_326: '-0XA', + + NUMBER_401: '0b1010', + NUMBER_402: '+0b1010', + NUMBER_403: '-0b1010', + NUMBER_404: '0B1010', + NUMBER_405: '+0B1010', + NUMBER_406: '-0B1010', + NUMBER_411: '0o12', + NUMBER_412: '+0o12', + NUMBER_413: '-0o12', + NUMBER_414: '0O12', + NUMBER_415: '+0O12', + NUMBER_416: '-0O12', + NUMBER_421: '0xa', + NUMBER_422: '+0xa', + NUMBER_423: '-0xa', + NUMBER_424: '0XA', + NUMBER_425: '+0XA', + NUMBER_426: '-0XA', + } + + // executes + const dotenvConfig = useEnv(input) + const dotenvConversionConfig = dotenvConversion.convert(Object.assign(options, dotenvConfig)) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:bigint', function (done) { // input const input = 'method.bigint' @@ -5655,6 +6793,106 @@ describe('dotenv-conversion', function () { done() }) + it('method:bigint:boh>>false', function (done) { + // input + const options = { + binaryBigInt: false, + octalBigInt: false, + hexadecimalBigInt: false, + } + const input = 'method.bigint.boh.false' + + // expected output + const expected = { + BIGINT_301: '0b1010n', + BIGINT_302: '+0b1010n', + BIGINT_303: '-0b1010n', + BIGINT_304: '0B1010n', + BIGINT_305: '+0B1010n', + BIGINT_306: '-0B1010n', + BIGINT_311: '0o12n', + BIGINT_312: '+0o12n', + BIGINT_313: '-0o12n', + BIGINT_314: '0O12n', + BIGINT_315: '+0O12n', + BIGINT_316: '-0O12n', + BIGINT_321: '0xan', + BIGINT_322: '+0xan', + BIGINT_323: '-0xan', + BIGINT_324: '0XAn', + BIGINT_325: '+0XAn', + BIGINT_326: '-0XAn', + + BIGINT_401: '0b1010n', + BIGINT_402: '+0b1010n', + BIGINT_403: '-0b1010n', + BIGINT_404: '0B1010n', + BIGINT_405: '+0B1010n', + BIGINT_406: '-0B1010n', + BIGINT_411: '0o12n', + BIGINT_412: '+0o12n', + BIGINT_413: '-0o12n', + BIGINT_414: '0O12n', + BIGINT_415: '+0O12n', + BIGINT_416: '-0O12n', + BIGINT_421: '0xan', + BIGINT_422: '+0xan', + BIGINT_423: '-0xan', + BIGINT_424: '0XAn', + BIGINT_425: '+0XAn', + BIGINT_426: '-0XAn', + } + const expectedForEnv = { + BIGINT_301: '0b1010n', + BIGINT_302: '+0b1010n', + BIGINT_303: '-0b1010n', + BIGINT_304: '0B1010n', + BIGINT_305: '+0B1010n', + BIGINT_306: '-0B1010n', + BIGINT_311: '0o12n', + BIGINT_312: '+0o12n', + BIGINT_313: '-0o12n', + BIGINT_314: '0O12n', + BIGINT_315: '+0O12n', + BIGINT_316: '-0O12n', + BIGINT_321: '0xan', + BIGINT_322: '+0xan', + BIGINT_323: '-0xan', + BIGINT_324: '0XAn', + BIGINT_325: '+0XAn', + BIGINT_326: '-0XAn', + + BIGINT_401: '0b1010n', + BIGINT_402: '+0b1010n', + BIGINT_403: '-0b1010n', + BIGINT_404: '0B1010n', + BIGINT_405: '+0B1010n', + BIGINT_406: '-0B1010n', + BIGINT_411: '0o12n', + BIGINT_412: '+0o12n', + BIGINT_413: '-0o12n', + BIGINT_414: '0O12n', + BIGINT_415: '+0O12n', + BIGINT_416: '-0O12n', + BIGINT_421: '0xan', + BIGINT_422: '+0xan', + BIGINT_423: '-0xan', + BIGINT_424: '0XAn', + BIGINT_425: '+0XAn', + BIGINT_426: '-0XAn', + } + + // executes + const dotenvConfig = useEnv(input) + const dotenvConversionConfig = dotenvConversion.convert(Object.assign(options, dotenvConfig)) + + // asserts + expect(dotenvConversionConfig.parsed).to.deep.equal(expected) + expect(process.env).to.deep.include(expectedForEnv) + + done() + }) + it('method:string', function (done) { // input const input = 'method.string' diff --git a/tests/inputs/method.auto.bigint.boh.false.env b/tests/inputs/method.auto.bigint.boh.false.env new file mode 100644 index 0000000..91b162e --- /dev/null +++ b/tests/inputs/method.auto.bigint.boh.false.env @@ -0,0 +1,18 @@ +BIGINT_201=0b1010n +BIGINT_202=+0b1010n +BIGINT_203=-0b1010n +BIGINT_204=0B1010n +BIGINT_205=+0B1010n +BIGINT_206=-0B1010n +BIGINT_211=0o12n +BIGINT_212=+0o12n +BIGINT_213=-0o12n +BIGINT_214=0O12n +BIGINT_215=+0O12n +BIGINT_216=-0O12n +BIGINT_221=0xan +BIGINT_222=+0xan +BIGINT_223=-0xan +BIGINT_224=0XAn +BIGINT_225=+0XAn +BIGINT_226=-0XAn diff --git a/tests/inputs/method.auto.number.boh.false.env b/tests/inputs/method.auto.number.boh.false.env new file mode 100644 index 0000000..3c3d719 --- /dev/null +++ b/tests/inputs/method.auto.number.boh.false.env @@ -0,0 +1,18 @@ +NUMBER_301=0b1010 +NUMBER_302=+0b1010 +NUMBER_303=-0b1010 +NUMBER_304=0B1010 +NUMBER_305=+0B1010 +NUMBER_306=-0B1010 +NUMBER_311=0o12 +NUMBER_312=+0o12 +NUMBER_313=-0o12 +NUMBER_314=0O12 +NUMBER_315=+0O12 +NUMBER_316=-0O12 +NUMBER_321=0xa +NUMBER_322=+0xa +NUMBER_323=-0xa +NUMBER_324=0XA +NUMBER_325=+0XA +NUMBER_326=-0XA diff --git a/tests/inputs/method.bigint.boh.false.env b/tests/inputs/method.bigint.boh.false.env new file mode 100644 index 0000000..f101842 --- /dev/null +++ b/tests/inputs/method.bigint.boh.false.env @@ -0,0 +1,37 @@ +BIGINT_301=bigint:0b1010n +BIGINT_302=bigint:+0b1010n +BIGINT_303=bigint:-0b1010n +BIGINT_304=bigint:0B1010n +BIGINT_305=bigint:+0B1010n +BIGINT_306=bigint:-0B1010n +BIGINT_311=bigint:0o12n +BIGINT_312=bigint:+0o12n +BIGINT_313=bigint:-0o12n +BIGINT_314=bigint:0O12n +BIGINT_315=bigint:+0O12n +BIGINT_316=bigint:-0O12n +BIGINT_321=bigint:0xan +BIGINT_322=bigint:+0xan +BIGINT_323=bigint:-0xan +BIGINT_324=bigint:0XAn +BIGINT_325=bigint:+0XAn +BIGINT_326=bigint:-0XAn + +BIGINT_401=bigint:0b1010 +BIGINT_402=bigint:+0b1010 +BIGINT_403=bigint:-0b1010 +BIGINT_404=bigint:0B1010 +BIGINT_405=bigint:+0B1010 +BIGINT_406=bigint:-0B1010 +BIGINT_411=bigint:0o12 +BIGINT_412=bigint:+0o12 +BIGINT_413=bigint:-0o12 +BIGINT_414=bigint:0O12 +BIGINT_415=bigint:+0O12 +BIGINT_416=bigint:-0O12 +BIGINT_421=bigint:0xa +BIGINT_422=bigint:+0xa +BIGINT_423=bigint:-0xa +BIGINT_424=bigint:0XA +BIGINT_425=bigint:+0XA +BIGINT_426=bigint:-0XA diff --git a/tests/inputs/method.boolean.boh.false.env b/tests/inputs/method.boolean.boh.false.env new file mode 100644 index 0000000..3263570 --- /dev/null +++ b/tests/inputs/method.boolean.boh.false.env @@ -0,0 +1,75 @@ +BOOLEAN_401=boolean:0b1010 +BOOLEAN_402=boolean:+0b1010 +BOOLEAN_403=boolean:-0b1010 +BOOLEAN_404=boolean:0B1010 +BOOLEAN_405=boolean:+0B1010 +BOOLEAN_406=boolean:-0B1010 +BOOLEAN_411=boolean:0o12 +BOOLEAN_412=boolean:+0o12 +BOOLEAN_413=boolean:-0o12 +BOOLEAN_414=boolean:0O12 +BOOLEAN_415=boolean:+0O12 +BOOLEAN_416=boolean:-0O12 +BOOLEAN_421=boolean:0xa +BOOLEAN_422=boolean:+0xa +BOOLEAN_423=boolean:-0xa +BOOLEAN_424=boolean:0XA +BOOLEAN_425=boolean:+0XA +BOOLEAN_426=boolean:-0XA + +BOOLEAN_501=boolean:0b0 +BOOLEAN_502=boolean:+0b0 +BOOLEAN_503=boolean:-0b0 +BOOLEAN_504=boolean:0B0 +BOOLEAN_505=boolean:+0B0 +BOOLEAN_506=boolean:-0B0 +BOOLEAN_511=boolean:0o0 +BOOLEAN_512=boolean:+0o0 +BOOLEAN_513=boolean:-0o0 +BOOLEAN_514=boolean:0O0 +BOOLEAN_515=boolean:+0O0 +BOOLEAN_516=boolean:-0O0 +BOOLEAN_521=boolean:0x0 +BOOLEAN_522=boolean:+0x0 +BOOLEAN_523=boolean:-0x0 +BOOLEAN_524=boolean:0X0 +BOOLEAN_525=boolean:+0X0 +BOOLEAN_526=boolean:-0X0 + +BOOLEAN_601=boolean:0b1010n +BOOLEAN_602=boolean:+0b1010n +BOOLEAN_603=boolean:-0b1010n +BOOLEAN_604=boolean:0B1010n +BOOLEAN_605=boolean:+0B1010n +BOOLEAN_606=boolean:-0B1010n +BOOLEAN_611=boolean:0o12n +BOOLEAN_612=boolean:+0o12n +BOOLEAN_613=boolean:-0o12n +BOOLEAN_614=boolean:0O12n +BOOLEAN_615=boolean:+0O12n +BOOLEAN_616=boolean:-0O12n +BOOLEAN_621=boolean:0xan +BOOLEAN_622=boolean:+0xan +BOOLEAN_623=boolean:-0xan +BOOLEAN_624=boolean:0XAn +BOOLEAN_625=boolean:+0XAn +BOOLEAN_626=boolean:-0XAn + +BOOLEAN_701=boolean:0b0n +BOOLEAN_702=boolean:+0b0n +BOOLEAN_703=boolean:-0b0n +BOOLEAN_704=boolean:0B0n +BOOLEAN_705=boolean:+0B0n +BOOLEAN_706=boolean:-0B0n +BOOLEAN_711=boolean:0o0n +BOOLEAN_712=boolean:+0o0n +BOOLEAN_713=boolean:-0o0n +BOOLEAN_714=boolean:0O0n +BOOLEAN_715=boolean:+0O0n +BOOLEAN_716=boolean:-0O0n +BOOLEAN_721=boolean:0x0n +BOOLEAN_722=boolean:+0x0n +BOOLEAN_723=boolean:-0x0n +BOOLEAN_724=boolean:0X0n +BOOLEAN_725=boolean:+0X0n +BOOLEAN_726=boolean:-0X0n diff --git a/tests/inputs/method.number.boh.false.env b/tests/inputs/method.number.boh.false.env new file mode 100644 index 0000000..a473e51 --- /dev/null +++ b/tests/inputs/method.number.boh.false.env @@ -0,0 +1,37 @@ +NUMBER_301=number:0b1010 +NUMBER_302=number:+0b1010 +NUMBER_303=number:-0b1010 +NUMBER_304=number:0B1010 +NUMBER_305=number:+0B1010 +NUMBER_306=number:-0B1010 +NUMBER_311=number:0o12 +NUMBER_312=number:+0o12 +NUMBER_313=number:-0o12 +NUMBER_314=number:0O12 +NUMBER_315=number:+0O12 +NUMBER_316=number:-0O12 +NUMBER_321=number:0xa +NUMBER_322=number:+0xa +NUMBER_323=number:-0xa +NUMBER_324=number:0XA +NUMBER_325=number:+0XA +NUMBER_326=number:-0XA + +NUMBER_401=number:0b1010n +NUMBER_402=number:+0b1010n +NUMBER_403=number:-0b1010n +NUMBER_404=number:0B1010n +NUMBER_405=number:+0B1010n +NUMBER_406=number:-0B1010n +NUMBER_411=number:0o12n +NUMBER_412=number:+0o12n +NUMBER_413=number:-0o12n +NUMBER_414=number:0O12n +NUMBER_415=number:+0O12n +NUMBER_416=number:-0O12n +NUMBER_421=number:0xan +NUMBER_422=number:+0xan +NUMBER_423=number:-0xan +NUMBER_424=number:0XAn +NUMBER_425=number:+0XAn +NUMBER_426=number:-0XAn