Skip to content

Commit d214811

Browse files
authored
Merge pull request #20 from ctavan/update-dependencies
Update dependencies
2 parents 6bd52b7 + 107212f commit d214811

File tree

9 files changed

+173
-109
lines changed

9 files changed

+173
-109
lines changed

.github/workflows/node.js.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: ['master']
9+
pull_request:
10+
branches: ['master']
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [18.x, 20.x, 22.x]
19+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
28+
- run: npm ci
29+
- run: npm run build --if-present
30+
- run: npm test

.travis.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ if (Math.random() < abTestRatio) {
4848
}
4949

5050
const keywords = getenv.array('KEYWORDS');
51-
keywords.forEach(function(keyword) {
51+
keywords.forEach(function (keyword) {
5252
// console.log(keyword);
5353
});
5454

5555
const primes = getenv.array('PRIMES', 'int');
56-
primes.forEach(function(prime) {
56+
primes.forEach(function (prime) {
5757
// console.log(prime, typeof prime);
5858
});
5959
```
@@ -149,6 +149,10 @@ console.log(getenv('RANDOM'));
149149

150150
## Changelog
151151

152+
### v1.1.0
153+
154+
- Add separator option to `env.array()` (#19)
155+
152156
### v1.0.0
153157

154158
- Drop support for Node.js older than 6.

index.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ function _value(varName, fallback) {
2828
}
2929

3030
const convert = {
31-
string: function(value) {
31+
string: function (value) {
3232
return '' + value;
3333
},
34-
int: function(value) {
34+
int: function (value) {
3535
const isInt = value.match(/^-?\d+$/);
3636
if (!isInt) {
3737
throw new Error('GetEnv.NoInteger: ' + value + ' is not an integer.');
3838
}
3939

4040
return +value;
4141
},
42-
float: function(value) {
42+
float: function (value) {
4343
const isInfinity = +value === Infinity || +value === -Infinity;
4444
if (isInfinity) {
4545
throw new Error('GetEnv.Infinity: ' + value + ' is set to +/-Infinity.');
@@ -52,15 +52,16 @@ const convert = {
5252

5353
return +value;
5454
},
55-
bool: function(value) {
56-
const isBool = (value || '').toLowerCase() === 'true' || (value || '').toLowerCase() === 'false';
55+
bool: function (value) {
56+
const isBool =
57+
(value || '').toLowerCase() === 'true' || (value || '').toLowerCase() === 'false';
5758
if (!isBool) {
5859
throw new Error('GetEnv.NoBoolean: ' + value + ' is not a boolean.');
5960
}
6061

6162
return (value || '').toLowerCase() === 'true';
6263
},
63-
boolish: function(value) {
64+
boolish: function (value) {
6465
try {
6566
return convert.bool(value);
6667
} catch (err) {
@@ -76,7 +77,7 @@ const convert = {
7677
};
7778

7879
function converter(type) {
79-
return function(varName, fallback) {
80+
return function (varName, fallback) {
8081
if (typeof varName == 'string') {
8182
// default
8283
const value = _value(varName, fallback);
@@ -90,7 +91,7 @@ function converter(type) {
9091

9192
const getenv = converter('string');
9293

93-
Object.keys(convert).forEach(function(type) {
94+
Object.keys(convert).forEach(function (type) {
9495
getenv[type] = converter(type);
9596
});
9697

@@ -131,19 +132,19 @@ getenv.multi = function multi(spec) {
131132
return result;
132133
};
133134

134-
getenv.disableFallbacks = function() {
135+
getenv.disableFallbacks = function () {
135136
fallbacksDisabled = true;
136137
};
137138

138-
getenv.enableFallbacks = function() {
139+
getenv.enableFallbacks = function () {
139140
fallbacksDisabled = false;
140141
};
141142

142-
getenv.disableErrors = function() {
143+
getenv.disableErrors = function () {
143144
throwError = false;
144145
};
145146

146-
getenv.enableErrors = function() {
147+
getenv.enableErrors = function () {
147148
throwError = true;
148149
};
149150

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
},
1919
"main": "index.js",
2020
"scripts": {
21-
"prettier": "prettier --write *.{js,md} **/*.js",
22-
"test": "bash -ec 'for F in test/*.js; do echo \"$F\": ; node $F; done;'"
21+
"prettier": "prettier --check .",
22+
"unit": "bash -ec 'for F in test/*.js; do echo \"$F\": ; node $F; done;'",
23+
"test": "npm run prettier && npm run unit"
2324
},
2425
"engines": {
2526
"node": ">=6"
2627
},
2728
"dependencies": {},
2829
"devDependencies": {
29-
"prettier": "^1.18.2"
30+
"prettier": "^3.5.3"
3031
},
3132
"keywords": [
3233
"env",

test/disableErrors.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ const getenv = require('../index');
44

55
const tests = {};
66

7-
tests['getenv.disableErrors() should disable any errors'] = function() {
7+
tests['getenv.disableErrors() should disable any errors'] = function () {
88
getenv.disableErrors();
99
assert.strictEqual(getenv.string('url', 'http://localhost'), 'http://localhost');
1010
assert(getenv.string('url'), undefined);
1111
};
1212

13-
tests['getenv.enableErrors() should enable errors'] = function() {
13+
tests['getenv.enableErrors() should enable errors'] = function () {
1414
getenv.enableErrors();
15-
assert.throws(function() {
15+
assert.throws(function () {
1616
getenv.string('url');
1717
});
1818
assert.strictEqual(getenv.string('url', 'http://localhost'), 'http://localhost');
1919
};
2020

21-
Object.keys(tests).forEach(function(key) {
21+
Object.keys(tests).forEach(function (key) {
2222
console.log('Test: %s', key);
2323
tests[key]();
2424
});

test/fallbacks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const getenv = require('../index');
55
const tests = {};
66

77
// order dependent test
8-
tests['getenv.disableFallbacks() makes relying on fallbacks an error'] = function() {
8+
tests['getenv.disableFallbacks() makes relying on fallbacks an error'] = function () {
99
getenv.disableFallbacks();
10-
assert.throws(function() {
10+
assert.throws(function () {
1111
getenv.string('url', 'http://localhost');
1212
});
1313
getenv.enableFallbacks();
1414
};
1515

16-
Object.keys(tests).forEach(function(key) {
16+
Object.keys(tests).forEach(function (key) {
1717
console.log('Test: %s', key);
1818
tests[key]();
1919
});

0 commit comments

Comments
 (0)