@nitra/check-env 3.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +0 -3
  2. package/package.json +5 -2
  3. package/src/index.js +11 -10
package/README.md CHANGED
@@ -4,9 +4,6 @@ Check that the critical environment variables are set for your app,
4
4
  and that you did not leave dangerous development overrides in production.
5
5
 
6
6
  [![NPM](https://img.shields.io/npm/v/@nitra/check-env?color=red)](https://www.npmjs.com/package/@nitra/check-env)
7
- [![MIT License](https://img.shields.io/github/license/47ng/check-env.svg?color=blue)](https://github.com/47ng/check-env/blob/next/LICENSE)
8
- [![Continuous Integration](https://github.com/47ng/check-env/workflows/Continuous%20Integration/badge.svg?branch=next)](https://github.com/47ng/check-env/actions)
9
- [![Coverage Status](https://coveralls.io/repos/github/47ng/check-env/badge.svg?branch=next)](https://coveralls.io/github/47ng/check-env?branch=next)
10
7
 
11
8
  ## Installation
12
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/check-env",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "description": "Check that the critical environment variables are set",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -30,5 +30,8 @@
30
30
  "files": [
31
31
  "src",
32
32
  "types"
33
- ]
33
+ ],
34
+ "dependencies": {
35
+ "@nitra/pino": "^2.3.0"
36
+ }
34
37
  }
package/src/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import process from 'node:process'
2
+ import log from '@nitra/pino'
2
3
 
3
4
  const testEnv = name => !process.env[name]
4
5
 
5
6
  const displayMissing = name => {
6
- console.error(`❌ Missing required environment variable ${name}`)
7
+ log.error(`❌ Missing required environment variable ${name}`)
7
8
  }
8
9
 
9
10
  /**
10
11
  * MissingEnvironmentVariableError
11
- *
12
12
  * @class
13
- * @extends Error
13
+ * @augments Error
14
14
  */
15
15
  export class MissingEnvironmentVariableError extends Error {
16
16
  constructor(envs) {
@@ -23,14 +23,13 @@ const checked = new Set()
23
23
 
24
24
  /**
25
25
  * Перевірка наявності змінних середовища
26
- *
27
26
  * @function
28
- * @param {Array.<String>} required
27
+ * @param {Array.<string>} required
29
28
  */
30
29
  export const checkEnv = required => {
31
30
  const missingReq = []
32
31
 
33
- required.forEach(name => {
32
+ for (const name of required) {
34
33
  // додаємо в список перевірених
35
34
  checked.add(name)
36
35
 
@@ -38,7 +37,7 @@ export const checkEnv = required => {
38
37
  displayMissing(name)
39
38
  missingReq.push(name)
40
39
  }
41
- })
40
+ }
42
41
 
43
42
  if (missingReq.length > 0) {
44
43
  throw new MissingEnvironmentVariableError(missingReq)
@@ -47,15 +46,17 @@ export const checkEnv = required => {
47
46
 
48
47
  /**
49
48
  * Для сумісності з попередніми версіями
50
- *
51
- * @param {Array.<String>} required to capture
49
+ * @param {Array.<string>} required to capture
52
50
  */
53
51
  export default checkEnv
54
52
 
55
53
  const envProxyHandler = {
56
54
  /**
57
55
  * Set colour of object
58
- * @returns {String}
56
+ * @param target
57
+ * @param prop
58
+ * @param _
59
+ * @returns {string}
59
60
  */
60
61
  get(target, prop, _) {
61
62
  // Якщо зі списку перевірених то повертаємо значення