@naturalcycles/nodejs-lib 12.84.0 → 12.85.1
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.
package/dist/script/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runScript = void 0;
|
|
4
|
+
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
|
+
const inspectAny_1 = require("../string/inspectAny");
|
|
4
6
|
const { DEBUG_RUN_SCRIPT } = process.env;
|
|
5
7
|
/**
|
|
6
8
|
* Use it in your top-level scripts like this:
|
|
@@ -21,6 +23,7 @@ const { DEBUG_RUN_SCRIPT } = process.env;
|
|
|
21
23
|
* Set env DEBUG_RUN_SCRIPT for extra debugging.
|
|
22
24
|
*/
|
|
23
25
|
function runScript(fn, opt = {}) {
|
|
26
|
+
(0, js_lib_1.setGlobalStringifyFunction)(inspectAny_1.inspectAnyStringifyFn);
|
|
24
27
|
const { logger = console, noExit } = opt;
|
|
25
28
|
process.on('uncaughtException', err => {
|
|
26
29
|
logger.error('uncaughtException:', err);
|
|
@@ -10,7 +10,7 @@ const INSPECT_OPT = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Just a convenience export of a const that fulfills the JsonStringifyFunction interface.
|
|
12
12
|
*/
|
|
13
|
-
const inspectAnyStringifyFn = obj =>
|
|
13
|
+
const inspectAnyStringifyFn = obj => (0, node_util_1.inspect)(obj, INSPECT_OPT);
|
|
14
14
|
exports.inspectAnyStringifyFn = inspectAnyStringifyFn;
|
|
15
15
|
/**
|
|
16
16
|
* Transforms ANY to human-readable string (via util.inspect mainly).
|
|
@@ -61,7 +61,7 @@ exports.unixTimestampSchema = exports.numberSchema.integer().min(0).max(TS_2500)
|
|
|
61
61
|
/**
|
|
62
62
|
* Between years 2000 and 2050
|
|
63
63
|
*/
|
|
64
|
-
exports.unixTimestamp2000Schema = exports.numberSchema.integer().min(
|
|
64
|
+
exports.unixTimestamp2000Schema = exports.numberSchema.integer().min(TS_2000).max(TS_2500);
|
|
65
65
|
/**
|
|
66
66
|
* Between years 1970 and 2050
|
|
67
67
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.85.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"docs-serve": "vuepress dev docs",
|
|
@@ -49,8 +49,7 @@
|
|
|
49
49
|
"prettier": "^2.0.0",
|
|
50
50
|
"vue-class-component": "^7.2.6",
|
|
51
51
|
"vuepress": "^1.7.1",
|
|
52
|
-
"vuepress-plugin-typescript": "^0.3.1"
|
|
53
|
-
"zod": "^3.19.1"
|
|
52
|
+
"vuepress-plugin-typescript": "^0.3.1"
|
|
54
53
|
},
|
|
55
54
|
"bin": {
|
|
56
55
|
"del": "dist/bin/del.js",
|
package/src/script/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { setGlobalStringifyFunction } from '@naturalcycles/js-lib'
|
|
1
2
|
import type { CommonLogger } from '@naturalcycles/js-lib'
|
|
3
|
+
import { inspectAnyStringifyFn } from '../string/inspectAny'
|
|
2
4
|
|
|
3
5
|
export interface RunScriptOptions {
|
|
4
6
|
/**
|
|
@@ -35,6 +37,8 @@ const { DEBUG_RUN_SCRIPT } = process.env
|
|
|
35
37
|
* Set env DEBUG_RUN_SCRIPT for extra debugging.
|
|
36
38
|
*/
|
|
37
39
|
export function runScript(fn: (...args: any[]) => any, opt: RunScriptOptions = {}): void {
|
|
40
|
+
setGlobalStringifyFunction(inspectAnyStringifyFn)
|
|
41
|
+
|
|
38
42
|
const { logger = console, noExit } = opt
|
|
39
43
|
|
|
40
44
|
process.on('uncaughtException', err => {
|
package/src/string/inspectAny.ts
CHANGED
|
@@ -11,7 +11,7 @@ const INSPECT_OPT: InspectOptions = {
|
|
|
11
11
|
/**
|
|
12
12
|
* Just a convenience export of a const that fulfills the JsonStringifyFunction interface.
|
|
13
13
|
*/
|
|
14
|
-
export const inspectAnyStringifyFn: JsonStringifyFunction = obj =>
|
|
14
|
+
export const inspectAnyStringifyFn: JsonStringifyFunction = obj => inspect(obj, INSPECT_OPT)
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Transforms ANY to human-readable string (via util.inspect mainly).
|
|
@@ -82,7 +82,7 @@ export const unixTimestampSchema = numberSchema.integer().min(0).max(TS_2500)
|
|
|
82
82
|
/**
|
|
83
83
|
* Between years 2000 and 2050
|
|
84
84
|
*/
|
|
85
|
-
export const unixTimestamp2000Schema = numberSchema.integer().min(
|
|
85
|
+
export const unixTimestamp2000Schema = numberSchema.integer().min(TS_2000).max(TS_2500)
|
|
86
86
|
/**
|
|
87
87
|
* Between years 1970 and 2050
|
|
88
88
|
*/
|