@node-minify/run 10.3.0 → 10.4.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.
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ type RunCommandLineParams = {
|
|
|
9
9
|
data: string;
|
|
10
10
|
maxBuffer?: number;
|
|
11
11
|
timeout?: number;
|
|
12
|
+
silence?: boolean;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
15
|
* Run the command line with spawn.
|
|
@@ -16,19 +17,22 @@ type RunCommandLineParams = {
|
|
|
16
17
|
* @param data - Data to minify (piped to stdin)
|
|
17
18
|
* @param maxBuffer - Optional buffer limit in bytes. Defaults to 1024 * 1024 (1MB).
|
|
18
19
|
* @param timeout - Optional timeout in milliseconds. Process will be killed if it exceeds this limit.
|
|
20
|
+
* @param silence - Optional boolean to suppress console logging.
|
|
19
21
|
* @returns Promise with minified content from stdout
|
|
20
22
|
*/
|
|
21
23
|
declare function runCommandLine({
|
|
22
24
|
args,
|
|
23
25
|
data,
|
|
24
26
|
maxBuffer,
|
|
25
|
-
timeout
|
|
27
|
+
timeout,
|
|
28
|
+
silence
|
|
26
29
|
}: RunCommandLineParams): Promise<string>;
|
|
27
30
|
type RunParams = {
|
|
28
31
|
data: string;
|
|
29
32
|
args: string[];
|
|
30
33
|
maxBuffer?: number;
|
|
31
34
|
timeout?: number;
|
|
35
|
+
silence?: boolean;
|
|
32
36
|
};
|
|
33
37
|
/**
|
|
34
38
|
* Execute command with Java process.
|
|
@@ -36,13 +40,15 @@ type RunParams = {
|
|
|
36
40
|
* @param args - Command line arguments
|
|
37
41
|
* @param maxBuffer - Optional buffer limit in bytes. Defaults to 1024 * 1024 (1MB).
|
|
38
42
|
* @param timeout - Optional timeout in milliseconds. Process will be killed if it exceeds this limit.
|
|
43
|
+
* @param silence - Optional boolean to suppress console logging.
|
|
39
44
|
* @returns Promise with minified content from stdout
|
|
40
45
|
*/
|
|
41
46
|
declare function run({
|
|
42
47
|
data,
|
|
43
48
|
args,
|
|
44
49
|
maxBuffer,
|
|
45
|
-
timeout
|
|
50
|
+
timeout,
|
|
51
|
+
silence
|
|
46
52
|
}: RunParams): Promise<string>;
|
|
47
53
|
//#endregion
|
|
48
54
|
export { RunCommandLineParams, run, runCommandLine };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;AAQA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;AAQA;AAiBA;;;AAGI,KApBQ,oBAAA,GAoBR;EACA,IAAA,EAAA,MAAA,EAAA;EACA,IAAA,EAAA,MAAA;EACD,SAAA,CAAA,EAAA,MAAA;EAAuB,OAAA,CAAA,EAAA,MAAA;EAAO,OAAA,CAAA,EAAA,OAAA;AAEhC,CAAA;AAmBD;;;;;;;;;iBA3BsB,cAAA;;;;;;GAMnB,uBAAuB;KAIrB,SAAA;;;;;;;;;;;;;;;;iBAiBiB,GAAA;;;;;;GAMnB,YAAY"}
|
package/dist/index.js
CHANGED
|
@@ -12,14 +12,16 @@ import childProcess from "node:child_process";
|
|
|
12
12
|
* @param data - Data to minify (piped to stdin)
|
|
13
13
|
* @param maxBuffer - Optional buffer limit in bytes. Defaults to 1024 * 1024 (1MB).
|
|
14
14
|
* @param timeout - Optional timeout in milliseconds. Process will be killed if it exceeds this limit.
|
|
15
|
+
* @param silence - Optional boolean to suppress console logging.
|
|
15
16
|
* @returns Promise with minified content from stdout
|
|
16
17
|
*/
|
|
17
|
-
async function runCommandLine({ args, data, maxBuffer, timeout }) {
|
|
18
|
+
async function runCommandLine({ args, data, maxBuffer, timeout, silence }) {
|
|
18
19
|
return run({
|
|
19
20
|
data,
|
|
20
21
|
args,
|
|
21
22
|
maxBuffer,
|
|
22
|
-
timeout
|
|
23
|
+
timeout,
|
|
24
|
+
silence
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
@@ -28,9 +30,10 @@ async function runCommandLine({ args, data, maxBuffer, timeout }) {
|
|
|
28
30
|
* @param args - Command line arguments
|
|
29
31
|
* @param maxBuffer - Optional buffer limit in bytes. Defaults to 1024 * 1024 (1MB).
|
|
30
32
|
* @param timeout - Optional timeout in milliseconds. Process will be killed if it exceeds this limit.
|
|
33
|
+
* @param silence - Optional boolean to suppress console logging.
|
|
31
34
|
* @returns Promise with minified content from stdout
|
|
32
35
|
*/
|
|
33
|
-
async function run({ data, args, maxBuffer = 1024 * 1024, timeout }) {
|
|
36
|
+
async function run({ data, args, maxBuffer = 1024 * 1024, timeout, silence = false }) {
|
|
34
37
|
return new Promise((resolve, reject) => {
|
|
35
38
|
const stdoutChunks = [];
|
|
36
39
|
const stderrChunks = [];
|
|
@@ -46,7 +49,7 @@ async function run({ data, args, maxBuffer = 1024 * 1024, timeout }) {
|
|
|
46
49
|
reject(/* @__PURE__ */ new Error(`Process timed out after ${timeout}ms`));
|
|
47
50
|
}, timeout);
|
|
48
51
|
const handleError = (source) => (error) => {
|
|
49
|
-
console.error(`Error in ${source}:`, error);
|
|
52
|
+
if (!silence) console.error(`Error in ${source}:`, error);
|
|
50
53
|
};
|
|
51
54
|
child.on("error", (error) => {
|
|
52
55
|
if (settled) return;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright (c) 2011-2026 Rodolphe Stoclin\n * MIT Licensed\n */\n\nimport childProcess from \"node:child_process\";\n\nexport type RunCommandLineParams = {\n args: string[];\n data: string;\n maxBuffer?: number;\n timeout?: number;\n silence?: boolean;\n};\n\n/**\n * Run the command line with spawn.\n * @param args - Command line arguments for the Java process\n * @param data - Data to minify (piped to stdin)\n * @param maxBuffer - Optional buffer limit in bytes. Defaults to 1024 * 1024 (1MB).\n * @param timeout - Optional timeout in milliseconds. Process will be killed if it exceeds this limit.\n * @param silence - Optional boolean to suppress console logging.\n * @returns Promise with minified content from stdout\n */\nexport async function runCommandLine({\n args,\n data,\n maxBuffer,\n timeout,\n silence,\n}: RunCommandLineParams): Promise<string> {\n return run({ data, args, maxBuffer, timeout, silence });\n}\n\ntype RunParams = {\n data: string;\n args: string[];\n maxBuffer?: number;\n timeout?: number;\n silence?: boolean;\n};\n\n/**\n * Execute command with Java process.\n * @param data - Data to minify (piped to stdin)\n * @param args - Command line arguments\n * @param maxBuffer - Optional buffer limit in bytes. Defaults to 1024 * 1024 (1MB).\n * @param timeout - Optional timeout in milliseconds. Process will be killed if it exceeds this limit.\n * @param silence - Optional boolean to suppress console logging.\n * @returns Promise with minified content from stdout\n */\nexport async function run({\n data,\n args,\n maxBuffer = 1024 * 1024,\n timeout,\n silence = false,\n}: RunParams): Promise<string> {\n return new Promise((resolve, reject) => {\n const stdoutChunks: Buffer[] = [];\n const stderrChunks: Buffer[] = [];\n let stdoutLength = 0;\n let stderrLength = 0;\n let timeoutId: NodeJS.Timeout | undefined;\n let settled = false;\n\n const child = childProcess.spawn(\"java\", args, {\n stdio: \"pipe\",\n });\n\n if (timeout) {\n timeoutId = setTimeout(() => {\n if (settled || child.killed) return;\n settled = true;\n child.kill();\n reject(new Error(`Process timed out after ${timeout}ms`));\n }, timeout);\n }\n\n const handleError = (source: string) => (error: Error) => {\n if (!silence) {\n console.error(`Error in ${source}:`, error);\n }\n };\n\n child.on(\"error\", (error) => {\n if (settled) return;\n settled = true;\n if (timeoutId) clearTimeout(timeoutId);\n handleError(\"child\")(error);\n reject(new Error(`Process error: ${error.message}`));\n });\n\n child.stdin?.on(\"error\", handleError(\"child.stdin\"));\n child.stdout?.on(\"error\", handleError(\"child.stdout\"));\n child.stderr?.on(\"error\", handleError(\"child.stderr\"));\n\n child.on(\"exit\", (code: number | null) => {\n if (settled) return;\n settled = true;\n if (timeoutId) clearTimeout(timeoutId);\n const stderr = Buffer.concat(stderrChunks).toString(\"utf8\");\n if (code !== 0) {\n reject(new Error(stderr || `Process exited with code ${code}`));\n return;\n }\n\n resolve(Buffer.concat(stdoutChunks).toString(\"utf8\"));\n });\n\n child.stdout?.on(\"data\", (chunk: Buffer) => {\n stdoutChunks.push(chunk);\n stdoutLength += chunk.length;\n\n if (maxBuffer > 0 && stdoutLength > maxBuffer) {\n if (settled) return;\n settled = true;\n if (timeoutId) clearTimeout(timeoutId);\n child.kill();\n reject(new Error(\"stdout maxBuffer exceeded\"));\n return;\n }\n });\n\n child.stderr?.on(\"data\", (chunk: Buffer) => {\n stderrChunks.push(chunk);\n stderrLength += chunk.length;\n\n if (maxBuffer > 0 && stderrLength > maxBuffer) {\n if (settled) return;\n settled = true;\n if (timeoutId) clearTimeout(timeoutId);\n child.kill();\n reject(new Error(\"stderr maxBuffer exceeded\"));\n return;\n }\n });\n\n child.stdin?.end(data);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,eAAsB,eAAe,EACjC,MACA,MACA,WACA,SACA,WACsC;AACtC,QAAO,IAAI;EAAE;EAAM;EAAM;EAAW;EAAS;EAAS,CAAC;;;;;;;;;;;AAoB3D,eAAsB,IAAI,EACtB,MACA,MACA,YAAY,OAAO,MACnB,SACA,UAAU,SACiB;AAC3B,QAAO,IAAI,SAAS,SAAS,WAAW;EACpC,MAAM,eAAyB,EAAE;EACjC,MAAM,eAAyB,EAAE;EACjC,IAAI,eAAe;EACnB,IAAI,eAAe;EACnB,IAAI;EACJ,IAAI,UAAU;EAEd,MAAM,QAAQ,aAAa,MAAM,QAAQ,MAAM,EAC3C,OAAO,QACV,CAAC;AAEF,MAAI,QACA,aAAY,iBAAiB;AACzB,OAAI,WAAW,MAAM,OAAQ;AAC7B,aAAU;AACV,SAA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AAM;AACZ,2BAAO,IAAI,MAAM,4BAA4B,CAAC;AAC9C;;IAEN;AAEF,QAAM,OAAO,IAAI,KAAK;GACxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/run",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.0",
|
|
4
4
|
"description": "exec commands for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"dev": "tsdown src/index.ts --watch"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@node-minify/types": "10.
|
|
55
|
+
"@node-minify/types": "10.4.0"
|
|
56
56
|
}
|
|
57
57
|
}
|