Skip to content

Commit 4264a19

Browse files
committed
Added types to process envs, fix husky install
1 parent d953842 commit 4264a19

File tree

7 files changed

+205
-465
lines changed

7 files changed

+205
-465
lines changed

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module.exports = {
88
},
99
extends: [
1010
'plugin:@typescript-eslint/recommended',
11-
'prettier/@typescript-eslint',
1211
'plugin:prettier/recommended',
1312
'prettier',
1413
],
@@ -32,6 +31,6 @@ module.exports = {
3231
'@typescript-eslint/no-this-alias': 'off',
3332
'@typescript-eslint/no-var-requires': 'off',
3433
'@typescript-eslint/no-explicit-any': 'off',
35-
'@typescript-eslint/ban-ts-comment': 'off'
34+
'@typescript-eslint/ban-ts-comment': 'off',
3635
},
3736
}

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint && yarn prettier

.prettierrc.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
2-
"tabWidth": 4,
3-
"useTabs": false,
4-
"semi": false,
5-
"singleQuote": true,
6-
"trailingComma": "es5",
7-
"endOfLine": "lf"
2+
tabWidth: 4,
3+
useTabs: false,
4+
semi: false,
5+
singleQuote: true,
6+
trailingComma: 'es5',
7+
endOfLine: 'lf',
88
}

package.json

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "@nrchkb/logger",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"description": "Unified Logger for Node-RED nodes (using debug)",
55
"main": "src/index.js",
66
"scripts": {
77
"build": "tsc",
88
"test": "yarn build && cross-env DEBUG=LOGGER* mocha -r ts-node/register './src/**/*.test.[tj]s' --exit",
9-
"prettier": "prettier --write \"src/**/*.{js,ts}\"",
9+
"prettier": "prettier --write \"**/*.{js,ts}\"",
1010
"lint": "eslint src/**/*.{js,ts} --fix",
11-
"husky-run": "lint-staged"
11+
"postinstall": "husky install",
12+
"prepublishOnly": "pinst --disable",
13+
"postpublish": "pinst --enable"
1214
},
1315
"repository": {
1416
"type": "git",
@@ -31,36 +33,24 @@
3133
"debug": "^4.3.1"
3234
},
3335
"devDependencies": {
34-
"@types/mocha": "^8.2.0",
36+
"@types/mocha": "^8.2.1",
3537
"@types/node": "^10.17.50",
3638
"@types/node-red": "^1.1.1",
37-
"@typescript-eslint/eslint-plugin": "^4.15.0",
38-
"@typescript-eslint/parser": "^4.15.0",
39+
"@typescript-eslint/eslint-plugin": "^4.16.1",
40+
"@typescript-eslint/parser": "^4.16.1",
3941
"babel-eslint": "^10.1.0",
4042
"cross-env": "^7.0.3",
41-
"eslint": "^7.20.0",
42-
"eslint-config-prettier": "^7.2.0",
43+
"eslint": "^7.21.0",
44+
"eslint-config-prettier": "^8.1.0",
4345
"eslint-plugin-prettier": "^3.3.1",
44-
"husky": "^5.0.9",
45-
"lint-staged": "^10.5.4",
46+
"husky": "^5.1.3",
4647
"mocha": "^8.3.0",
4748
"node-red": "^1.2.9",
4849
"node-red-node-test-helper": "^0.2.7",
50+
"pinst": "^2.1.6",
4951
"prettier": "^2.2.1",
5052
"ts-node": "^9.1.1",
51-
"typescript": "^4.1.5"
52-
},
53-
"husky": {
54-
"hooks": {
55-
"pre-commit": "lint-staged"
56-
}
57-
},
58-
"lint-staged": {
59-
"*.{js,ts}": [
60-
"yarn lint",
61-
"yarn prettier",
62-
"git add"
63-
]
53+
"typescript": "^4.2.2"
6454
},
6555
"engines": {
6656
"node": ">=10.22.1"

src/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ import { CallbackType, Logger, LoggerSetupData } from './types'
44

55
const helpers = require('./helpers')
66

7-
let LOGGER_DEBUG_COLOR = process.env.LOGGER_DEBUG_COLOR || '4'
8-
let LOGGER_ERROR_COLOR = process.env.LOGGER_ERROR_COLOR || '9'
9-
let LOGGER_TRACE_COLOR = process.env.LOGGER_TRACE_COLOR || '15'
10-
let LOGGER_DEBUG_ENABLED =
11-
process.env.LOGGER_DEBUG_ENABLED &&
12-
process.env.LOGGER_DEBUG_ENABLED === 'true'
13-
let LOGGER_ERROR_ENABLED =
7+
let LOGGER_DEBUG_COLOR: string = process.env.LOGGER_DEBUG_COLOR || '4'
8+
let LOGGER_ERROR_COLOR: string = process.env.LOGGER_ERROR_COLOR || '9'
9+
let LOGGER_TRACE_COLOR: string = process.env.LOGGER_TRACE_COLOR || '15'
10+
let LOGGER_DEBUG_ENABLED: boolean =
11+
(process.env.LOGGER_DEBUG_ENABLED &&
12+
process.env.LOGGER_DEBUG_ENABLED === 'true') ||
13+
false
14+
let LOGGER_ERROR_ENABLED: boolean =
1415
(process.env.LOGGER_ERROR_ENABLED &&
1516
process.env.LOGGER_ERROR_ENABLED === 'true') ||
1617
true
17-
let LOGGER_TRACE_ENABLED =
18-
process.env.LOGGER_TRACE_ENABLED &&
19-
process.env.LOGGER_TRACE_ENABLED === 'true'
18+
let LOGGER_TRACE_ENABLED: boolean =
19+
(process.env.LOGGER_TRACE_ENABLED &&
20+
process.env.LOGGER_TRACE_ENABLED === 'true') ||
21+
false
2022

2123
let LOGGER_TIMESTAMP_ENABLED = process.env.LOGGER_TIMESTAMP_ENABLED || false
2224

0 commit comments

Comments
 (0)