Skip to content

Commit

Permalink
fix grammatical
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre authored and Andre committed Nov 7, 2023
1 parent 5ee64a3 commit 07e1715
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# version 2.0.2

## 11/07/2023

- fix grammatical

# version 2.0.1

## 11/06/2023
Expand Down
4 changes: 2 additions & 2 deletions __tests__/parsEnvironmentFileString.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const fs = require('fs');
const path = require('path');
const { parsEnvironmentFileString } = require('../lib/parsEnvironmentFileString');
const { parseEnvironmentFileString } = require('../lib/parseEnvironmentFileString');

describe('test filterEmptyLines', () => {
test('test filter empty values', () => {
Expand All @@ -11,7 +11,7 @@ describe('test filterEmptyLines', () => {
.readFileSync(path.join(__dirname, '.env.test'), 'utf-8')
.trim();

const array = parsEnvironmentFileString(readEnvironmentFile);
const array = parseEnvironmentFileString(readEnvironmentFile);
expect(typeof array).toEqual('object');
});
});
16 changes: 7 additions & 9 deletions docs/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* [parseValue][9]
* [Parameters][10]
* [getProcessEnv][11]
* [parsEnvironmentFileString][12]
* [parseEnvironmentFileString][12]
* [Parameters][13]
* [replaceNestedChars][14]
* [Parameters][15]
Expand Down Expand Up @@ -74,11 +74,11 @@ Returns **([object][21] | [string][19])** **value**
## getProcessEnv

This function parse the Global Super process.env
The values in process.env will be parsed by [parsValue][22]
The values in process.env will be parsed by [parseValue][9]

Returns **[object][21]** **env**

## parsEnvironmentFileString
## parseEnvironmentFileString

This function parse the environment file to an Object

Expand Down Expand Up @@ -123,7 +123,7 @@ You can use inline comments and masked hashtags (\\#)
* `key` **[string][19]?** 
* `defaultValue` **any?** 

Returns **([string][19] | [object][21] | [array][20] | [function][23] | [undefined][24])** **value**
Returns **([string][19] | [object][21] | [array][20] | [function][22] | [undefined][23])** **value**

[1]: #filtercommentinlines

Expand All @@ -147,7 +147,7 @@ Returns **([string][19] | [object][21] | [array][20] | [function][23] | [undefin

[11]: #getprocessenv

[12]: #parsenvironmentfilestring
[12]: #parseenvironmentfilestring

[13]: #parameters-5

Expand All @@ -167,8 +167,6 @@ Returns **([string][19] | [object][21] | [array][20] | [function][23] | [undefin

[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[22]: parsValue
[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[24]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
[23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
Expand Down
34 changes: 17 additions & 17 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ <h3 class='mb0 no-anchor'>processenv2</h3>


<li><a
href='#parsenvironmentfilestring'
href='#parseenvironmentfilestring'
class="">
parsEnvironmentFileString
parseEnvironmentFileString

</a>

Expand Down Expand Up @@ -137,7 +137,7 @@ <h3 class='fl m0' id='filtercommentinlines'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/filter/filterCommentInLines.js#L10-L43'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/filter/filterCommentInLines.js#L10-L43'>
<span>lib/filter/filterCommentInLines.js</span>
</a>

Expand Down Expand Up @@ -213,7 +213,7 @@ <h3 class='fl m0' id='filtercommentlines'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/filter/filterCommentLines.js#L10-L16'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/filter/filterCommentLines.js#L10-L16'>
<span>lib/filter/filterCommentLines.js</span>
</a>

Expand Down Expand Up @@ -289,7 +289,7 @@ <h3 class='fl m0' id='filteremptylines'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/filter/filterEmptyLines.js#L10-L17'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/filter/filterEmptyLines.js#L10-L17'>
<span>lib/filter/filterEmptyLines.js</span>
</a>

Expand Down Expand Up @@ -365,7 +365,7 @@ <h3 class='fl m0' id='removequotationmarks'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/filter/removeQuotationMarks.js#L10-L17'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/filter/removeQuotationMarks.js#L10-L17'>
<span>lib/filter/removeQuotationMarks.js</span>
</a>

Expand Down Expand Up @@ -441,15 +441,15 @@ <h3 class='fl m0' id='getprocessenv'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/getProcessEnv.js#L12-L22'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/getProcessEnv.js#L12-L22'>
<span>lib/getProcessEnv.js</span>
</a>

</div>


<p>This function parse the Global Super process.env
The values in process.env will be parsed by <a href="parsValue">parsValue</a></p>
The values in process.env will be parsed by <a href="#parsevalue">parseValue</a></p>

<div class='pre p1 fill-light mt0'>getProcessEnv(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></div>

Expand Down Expand Up @@ -499,21 +499,21 @@ <h3 class='fl m0' id='getprocessenv'>

<div class='clearfix'>

<h3 class='fl m0' id='parsenvironmentfilestring'>
parsEnvironmentFileString
<h3 class='fl m0' id='parseenvironmentfilestring'>
parseEnvironmentFileString
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/parsEnvironmentFileString.js#L18-L52'>
<span>lib/parsEnvironmentFileString.js</span>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/parseEnvironmentFileString.js#L18-L52'>
<span>lib/parseEnvironmentFileString.js</span>
</a>

</div>


<p>This function parse the environment file to an Object</p>

<div class='pre p1 fill-light mt0'>parsEnvironmentFileString(environmentString: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></div>
<div class='pre p1 fill-light mt0'>parseEnvironmentFileString(environmentString: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></div>



Expand Down Expand Up @@ -579,8 +579,8 @@ <h3 class='fl m0' id='parsevalue'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/parsValue.js#L10-L16'>
<span>lib/parsValue.js</span>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/parseValue.js#L10-L16'>
<span>lib/parseValue.js</span>
</a>

</div>
Expand Down Expand Up @@ -654,7 +654,7 @@ <h3 class='fl m0' id='processenv'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/processenv2.js#L21-L48'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/processenv2.js#L21-L48'>
<span>lib/processenv2.js</span>
</a>

Expand Down Expand Up @@ -742,7 +742,7 @@ <h3 class='fl m0' id='replacenestedchars'>
</h3>


<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/eb2d6afa7ea358466a355dc11d3b2ba379c74bd9/lib/replaceNestedChars.js#L19-L32'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/Nexus633/processenv2/blob/5ee64a33dcb158c48e77649bc020f90676bf9266/lib/replaceNestedChars.js#L19-L32'>
<span>lib/replaceNestedChars.js</span>
</a>

Expand Down
6 changes: 3 additions & 3 deletions lib/getProcessEnv.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
const { parsValue } = require('./parsValue');
const { parseValue } = require('./parseValue');

/**
* This function parse the Global Super process.env
* The values in process.env will be parsed by {@link parsValue}
* The values in process.env will be parsed by {@link parseValue}
*
* @function getProcessEnv
*
Expand All @@ -15,7 +15,7 @@ const getProcessEnv = () => {
// eslint-disable-next-line no-undef
Object.keys(process.env).forEach((name) => {
// eslint-disable-next-line no-undef
env[name] = parsValue(process.env[name]);
env[name] = parseValue(process.env[name]);
});

return env;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ const os = require('os');
const { filterCommentInLines } = require('./filter/filterCommentInLines');
const { filterCommentLines } = require('./filter/filterCommentLines');
const { filterEmptyLines } = require('./filter/filterEmptyLines');
const { parsValue } = require('./parsValue');
const { parseValue } = require('./parseValue');
const { removeQuotationMarks } = require('./filter/removeQuotationMarks');
const { replaceNestedChars } = require('./replaceNestedChars');

/**
* This function parse the environment file to an Object
*
* @function parsEnvironmentFileString
* @function parseEnvironmentFileString
*
* @param {string} environmentString
* @returns {object} **parsed environment variables**
*/
const parsEnvironmentFileString = (environmentString) => {
const parseEnvironmentFileString = (environmentString) => {
const env = {};
const environmentFileArray = environmentString.split(os.EOL);
const parsFilterEmptyLines = filterEmptyLines(environmentFileArray);
const parsFilterCommentLines = filterCommentLines(parsFilterEmptyLines);
const parseFilterEmptyLines = filterEmptyLines(environmentFileArray);
const parseFilterCommentLines = filterCommentLines(parseFilterEmptyLines);

parsFilterCommentLines.filter((val) => {
parseFilterCommentLines.filter((val) => {
const splitVal = val.split('=');
splitVal[0] = removeQuotationMarks(splitVal[0]);
splitVal[1] = removeQuotationMarks(splitVal[1]);
Expand All @@ -38,7 +38,7 @@ const parsEnvironmentFileString = (environmentString) => {
}
}

splitVal[1] = parsValue(splitVal[1]);
splitVal[1] = parseValue(splitVal[1]);
splitVal[1] = filterCommentInLines(splitVal[1]);
splitVal[0] = splitVal[0].trim();
if (typeof splitVal[1] === 'string') {
Expand All @@ -51,4 +51,4 @@ const parsEnvironmentFileString = (environmentString) => {
return env;
};

module.exports = { parsEnvironmentFileString };
module.exports = { parseEnvironmentFileString };
4 changes: 2 additions & 2 deletions lib/parsValue.js → lib/parseValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* @param {(object|string)} value
* @returns {(object|string)} **value**
*/
const parsValue = (value) => {
const parseValue = (value) => {
try {
return JSON.parse(value);
} catch (exception) {
return value;
}
};

module.exports = { parsValue };
module.exports = { parseValue };
4 changes: 2 additions & 2 deletions lib/processenv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const fs = require('fs');
const path = require('path');
const { getProcessEnv } = require('./getProcessEnv');
const { parsEnvironmentFileString } = require('./parsEnvironmentFileString');
const { parseEnvironmentFileString } = require('./parseEnvironmentFileString');

/**
* With **processenv2** you have the opportunity to use environment variables directly in your project.
Expand All @@ -26,7 +26,7 @@ const processenv = (key, defaultValue) => {

if (fs.existsSync(environmentFile)) {
const readEnvironmentFile = fs.readFileSync(environmentFile, 'utf-8').trim();
const parsedEnvironmentFile = parsEnvironmentFileString(readEnvironmentFile);
const parsedEnvironmentFile = parseEnvironmentFileString(readEnvironmentFile);

env = { ...env, ...parsedEnvironmentFile };
// eslint-disable-next-line no-undef
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "processenv2",
"version": "2.0.1",
"version": "2.0.2",
"description": "parse .env files to load variables to the process.env property automatically",
"main": "lib/processenv2.js",
"scripts": {
Expand Down

0 comments on commit 07e1715

Please sign in to comment.