Skip to content

Commit 3148f6d

Browse files
committed
fix: fixed array with just one variable (closes #19)
1 parent 8efc261 commit 3148f6d

File tree

5 files changed

+800
-964
lines changed

5 files changed

+800
-964
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"babel-plugin-add-module-exports": "^1.0.2",
1313
"babel-preset-crocodile": "^1.0.0",
1414
"chai": "^4.2.0",
15-
"codecov": "^3.5.0",
15+
"codecov": "^3.6.5",
1616
"dirty-chai": "^2.0.1",
17-
"dotenv": "^8.0.0",
17+
"dotenv": "^8.2.0",
1818
"eslint-config-crocodile": "^1.0.0",
1919
"istanbul": "^1.1.0-alpha.1",
2020
"mocha": "^6.1.4"

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ function parseKey(value, key) {
6363
// Array
6464
if (value.indexOf(',') !== -1) {
6565
debug(`key ${key} parsed as an Array`);
66-
return value.split(',').map(parseKey);
66+
return value.split(',').filter(function (str) {
67+
return str !== '';
68+
}).map(parseKey);
6769
}
6870

6971
return value;

test/fixtures/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FOO=bar
22
BAZ=2
33
BEEP=false
4+
ARR=single,
45
BOOP=some,thing,that,goes,wow
56
# note how we use an asterisk here to turn off the parsing for this variable
67
BLEEP=false*

test/fixtures/env.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
FOO: 'bar',
33
BAZ: 2,
44
BEEP: false,
5+
ARR: [ 'single' ],
56
BOOP: [ 'some', 'thing', 'that', 'goes', 'wow' ],
67
BLEEP: 'false',
78
PING: [ 'ping', 'true', 2, 100 ],

0 commit comments

Comments
 (0)