@naturalcycles/nodejs-lib 13.8.0 → 13.9.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/util/exec.util.d.ts +9 -2
- package/dist/util/exec.util.js +2 -0
- package/package.json +3 -3
- package/src/util/exec.util.ts +17 -7
package/dist/util/exec.util.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { SpawnOptions } from 'node:child_process';
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export interface ExecOptions extends SpawnOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Defaults to true.
|
|
6
|
+
* Set to false to skip logging.
|
|
7
|
+
*/
|
|
8
|
+
log?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function execVoidCommand(cmd: string, args?: string[], opt?: ExecOptions): Promise<void>;
|
|
11
|
+
export declare function execVoidCommandSync(cmd: string, args?: string[], opt?: ExecOptions): void;
|
package/dist/util/exec.util.js
CHANGED
|
@@ -48,6 +48,8 @@ function execVoidCommandSync(cmd, args = [], opt = {}) {
|
|
|
48
48
|
}
|
|
49
49
|
exports.execVoidCommandSync = execVoidCommandSync;
|
|
50
50
|
function logExec(cmd, args = [], opt = {}) {
|
|
51
|
+
if (opt.log === false)
|
|
52
|
+
return;
|
|
51
53
|
const cmdline = [
|
|
52
54
|
...Object.entries(opt.env || {}).map(([k, v]) => [k, v].join('=')),
|
|
53
55
|
cmd,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.9.1",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"prepare": "husky
|
|
5
|
+
"prepare": "husky",
|
|
6
6
|
"docs-serve": "vuepress dev docs",
|
|
7
7
|
"docs-build": "vuepress build docs",
|
|
8
8
|
"slack-this-debug": "tsn ./src/bin/slack-this.ts --channel test --msg 'Hello slack!'",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@types/jsonwebtoken": "^9.0.0",
|
|
20
20
|
"@types/through2-concurrent": "^2.0.0",
|
|
21
21
|
"ajv": "^8.6.2",
|
|
22
|
-
"ajv-formats": "^
|
|
22
|
+
"ajv-formats": "^3.0.1",
|
|
23
23
|
"ajv-keywords": "^5.0.0",
|
|
24
24
|
"binary-split": "^1.0.5",
|
|
25
25
|
"chalk": "^4.0.0",
|
package/src/util/exec.util.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { ProcessEnvOptions, SpawnOptions } from 'node:child_process'
|
|
2
2
|
import cp from 'node:child_process'
|
|
3
3
|
|
|
4
|
+
export interface ExecOptions extends SpawnOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Defaults to true.
|
|
7
|
+
* Set to false to skip logging.
|
|
8
|
+
*/
|
|
9
|
+
log?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
export async function execVoidCommand(
|
|
5
13
|
cmd: string,
|
|
6
14
|
args: string[] = [],
|
|
7
|
-
opt:
|
|
15
|
+
opt: ExecOptions = {},
|
|
8
16
|
): Promise<void> {
|
|
9
17
|
logExec(cmd, args, opt)
|
|
10
18
|
|
|
@@ -29,11 +37,7 @@ export async function execVoidCommand(
|
|
|
29
37
|
})
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
export function execVoidCommandSync(
|
|
33
|
-
cmd: string,
|
|
34
|
-
args: string[] = [],
|
|
35
|
-
opt: SpawnOptions = {},
|
|
36
|
-
): void {
|
|
40
|
+
export function execVoidCommandSync(cmd: string, args: string[] = [], opt: ExecOptions = {}): void {
|
|
37
41
|
logExec(cmd, args, opt)
|
|
38
42
|
|
|
39
43
|
const r = cp.spawnSync(cmd, [...args], {
|
|
@@ -58,7 +62,13 @@ export function execVoidCommandSync(
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
function logExec(
|
|
65
|
+
function logExec(
|
|
66
|
+
cmd: string,
|
|
67
|
+
args: string[] = [],
|
|
68
|
+
opt: ProcessEnvOptions & ExecOptions = {},
|
|
69
|
+
): void {
|
|
70
|
+
if (opt.log === false) return
|
|
71
|
+
|
|
62
72
|
const cmdline = [
|
|
63
73
|
...Object.entries(opt.env || {}).map(([k, v]) => [k, v].join('=')),
|
|
64
74
|
cmd,
|