@rzl-zone/build-tools 0.0.10 → 0.0.11
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/.references/index.d.cts +1 -1
- package/dist/.references/index.d.ts +1 -1
- package/dist/bundler/rolldown.cjs +2 -2
- package/dist/bundler/rolldown.d.cts +2 -2
- package/dist/bundler/rolldown.d.ts +2 -2
- package/dist/bundler/rolldown.js +1 -1
- package/dist/bundler/tsdown.cjs +3 -3
- package/dist/bundler/tsdown.d.cts +2 -2
- package/dist/bundler/tsdown.d.ts +2 -2
- package/dist/bundler/tsdown.js +3 -3
- package/dist/bundler/utils.cjs +2 -2
- package/dist/bundler/utils.d.cts +2 -2
- package/dist/bundler/utils.d.ts +2 -2
- package/dist/bundler/utils.js +2 -2
- package/dist/{client-DnTjQyyo.cjs → client-CuivP4z0.cjs} +3 -3
- package/dist/{client-DnTjQyyo.cjs.map → client-CuivP4z0.cjs.map} +1 -1
- package/dist/{client-BmfdVI22.js → client-DzeqTq6Y.js} +3 -3
- package/dist/{client-BmfdVI22.js.map → client-DzeqTq6Y.js.map} +1 -1
- package/dist/commander-kit/index.cjs +5 -5
- package/dist/commander-kit/index.d.cts +3 -3
- package/dist/commander-kit/index.d.ts +3 -3
- package/dist/commander-kit/index.js +5 -5
- package/dist/{extra-CYpD3D9p.d.ts → extra-BleSbKJp.d.ts} +2 -2
- package/dist/{extra-Dc_eIyiW.d.cts → extra-C8r3KWjP.d.cts} +2 -2
- package/dist/{fast-globe-options-BtIrCNb6.d.cts → fast-globe-options-D7S2fQZZ.d.cts} +3 -3
- package/dist/{fast-globe-options-CZ-9wIKV.d.ts → fast-globe-options-DnV58KJc.d.ts} +3 -3
- package/dist/{helper-CWU8QYq3.js → helper-C0AShk-j.js} +2 -2
- package/dist/{helper-CWU8QYq3.js.map → helper-C0AShk-j.js.map} +1 -1
- package/dist/{helper-DvCvgDxy.cjs → helper-DNj9Sj4w.cjs} +2 -2
- package/dist/{helper-DvCvgDxy.cjs.map → helper-DNj9Sj4w.cjs.map} +1 -1
- package/dist/{identity-xuDCNgfm.js → identity-CcYkvy9q.js} +6 -6
- package/dist/{identity-xuDCNgfm.js.map → identity-CcYkvy9q.js.map} +1 -1
- package/dist/{identity-D192lL-_.cjs → identity-Crq3bzhv.cjs} +6 -6
- package/dist/{identity-D192lL-_.cjs.map → identity-Crq3bzhv.cjs.map} +1 -1
- package/dist/{index-DW1JFluR.d.cts → index-BdtMQyzF.d.cts} +2 -2
- package/dist/{index-qft-a5kh.d.ts → index-CwHGSras.d.ts} +2 -2
- package/dist/{index-1FKLQ7ah.d.cts → index-DlH2PDPD.d.cts} +2 -2
- package/dist/{index-CEsO_rxz.d.ts → index-NLQcJJFO.d.ts} +2 -2
- package/dist/index.cjs +176 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -48
- package/dist/index.d.ts +81 -48
- package/dist/index.js +176 -104
- package/dist/index.js.map +1 -1
- package/dist/{package-banner-BHyF8RdG.cjs → package-banner-BoS7Lbi9.cjs} +5 -5
- package/dist/{package-banner-BHyF8RdG.cjs.map → package-banner-BoS7Lbi9.cjs.map} +1 -1
- package/dist/{package-banner-BmLNyezO.js → package-banner-DkNDAjMK.js} +5 -5
- package/dist/{package-banner-BmLNyezO.js.map → package-banner-DkNDAjMK.js.map} +1 -1
- package/dist/{server-DZvrqlyy.cjs → server-CvLC0e2m.cjs} +3 -3
- package/dist/{server-DZvrqlyy.cjs.map → server-CvLC0e2m.cjs.map} +1 -1
- package/dist/{server-BA7ruG1h.js → server-Dc93jndm.js} +3 -3
- package/dist/{server-BA7ruG1h.js.map → server-Dc93jndm.js.map} +1 -1
- package/dist/utils/client.cjs +2 -2
- package/dist/utils/client.d.cts +1 -1
- package/dist/utils/client.d.ts +1 -1
- package/dist/utils/client.js +2 -2
- package/dist/utils/server.cjs +2 -2
- package/dist/utils/server.d.cts +2 -2
- package/dist/utils/server.d.ts +2 -2
- package/dist/utils/server.js +2 -2
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.11`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-
|
|
12
|
-
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-
|
|
13
|
-
import { t as CommandIdentity } from "./index-
|
|
14
|
-
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-
|
|
11
|
+
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-C8r3KWjP.cjs";
|
|
12
|
+
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-DlH2PDPD.cjs";
|
|
13
|
+
import { t as CommandIdentity } from "./index-BdtMQyzF.cjs";
|
|
14
|
+
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-D7S2fQZZ.cjs";
|
|
15
15
|
import { ChildProcess, SpawnOptions, StdioOptions } from "node:child_process";
|
|
16
16
|
import * as acorn from "acorn";
|
|
17
17
|
|
|
@@ -1464,7 +1464,7 @@ type BaseRunCommandOptions = {
|
|
|
1464
1464
|
*/
|
|
1465
1465
|
env?: NodeJS.ProcessEnv;
|
|
1466
1466
|
/** ----------------------------------------------------------------
|
|
1467
|
-
* * ***
|
|
1467
|
+
* * ***Control whether the command is executed inside a system shell.***
|
|
1468
1468
|
* ----------------------------------------------------------------
|
|
1469
1469
|
*
|
|
1470
1470
|
* By default, commands are executed inside a system shell:
|
|
@@ -1474,13 +1474,18 @@ type BaseRunCommandOptions = {
|
|
|
1474
1474
|
* Set this option to `false` to bypass the shell and execute
|
|
1475
1475
|
* the command directly.
|
|
1476
1476
|
*
|
|
1477
|
-
* This is useful for:
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1477
|
+
* - This is useful for:
|
|
1478
|
+
* - Strict argument handling.
|
|
1479
|
+
* - Avoiding shell interpretation.
|
|
1480
|
+
*
|
|
1481
|
+
* - ⚠️ Note:
|
|
1482
|
+
* - Shell operators and advanced shell syntax (e.g. `&&`, `||`, `|`, `>`)
|
|
1483
|
+
* are **not supported**, regardless of this option.
|
|
1484
|
+
* - This utility always executes a single command with arguments.
|
|
1480
1485
|
*
|
|
1481
1486
|
* @default true (shell is enabled)
|
|
1482
1487
|
*/
|
|
1483
|
-
shell?:
|
|
1488
|
+
shell?: boolean;
|
|
1484
1489
|
/** ----------------------------------------------------------------
|
|
1485
1490
|
* * ***Abort signal for cancelling the spawned process.***
|
|
1486
1491
|
* ----------------------------------------------------------------
|
|
@@ -1552,6 +1557,7 @@ type BaseRunCommandOptions = {
|
|
|
1552
1557
|
*/
|
|
1553
1558
|
useColors?: boolean;
|
|
1554
1559
|
} & Omit<SpawnOptions, "cwd" | "env" | "shell" | "stdio" | "argv0" | "timeout">;
|
|
1560
|
+
type Reason = "timeout" | "abort" | "signal" | "non-zero exit code" | "validation";
|
|
1555
1561
|
/** ----------------------------------------------------------------
|
|
1556
1562
|
* * ***Represents a command execution failure.***
|
|
1557
1563
|
* ----------------------------------------------------------------
|
|
@@ -1626,7 +1632,7 @@ type BaseRunCommandOptions = {
|
|
|
1626
1632
|
* output when logged via `console.error`.
|
|
1627
1633
|
*/
|
|
1628
1634
|
declare class CommandProcessError extends Error {
|
|
1629
|
-
reason:
|
|
1635
|
+
reason: Reason;
|
|
1630
1636
|
exitCode?: number;
|
|
1631
1637
|
signal?: NodeJS.Signals | null;
|
|
1632
1638
|
command: string;
|
|
@@ -1753,6 +1759,18 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1753
1759
|
* - Parsing results (JSON, text, etc.).
|
|
1754
1760
|
* - Testing and scripting utilities.
|
|
1755
1761
|
*
|
|
1762
|
+
* ----------------------------------------------------------------
|
|
1763
|
+
* #### Limitations
|
|
1764
|
+
*
|
|
1765
|
+
* - Only a **single command** is supported.
|
|
1766
|
+
* - Shell syntax is **NOT allowed**, including:
|
|
1767
|
+
* - `&&`, `||`
|
|
1768
|
+
* - `|`
|
|
1769
|
+
* - `>`, `<`
|
|
1770
|
+
* - command chaining or piping of any kind
|
|
1771
|
+
*
|
|
1772
|
+
* Commands must represent a single executable with arguments.
|
|
1773
|
+
*
|
|
1756
1774
|
* @param {string} command
|
|
1757
1775
|
* The executable or command to run.
|
|
1758
1776
|
*
|
|
@@ -1774,33 +1792,34 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1774
1792
|
*
|
|
1775
1793
|
* This function does NOT reject on non-zero exit codes.
|
|
1776
1794
|
* - Instead, use:
|
|
1777
|
-
* - `result.ok
|
|
1778
|
-
* - `result.exitCode
|
|
1795
|
+
* - `result.ok`
|
|
1796
|
+
* - `result.exitCode`
|
|
1779
1797
|
*
|
|
1780
|
-
*
|
|
1781
|
-
*
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1784
|
-
*
|
|
1798
|
+
* The promise will reject in the following cases:
|
|
1799
|
+
* - validation errors (invalid command or arguments)
|
|
1800
|
+
* - spawn errors
|
|
1801
|
+
* - abort signals
|
|
1802
|
+
* - timeouts
|
|
1803
|
+
* - termination by signal
|
|
1785
1804
|
*
|
|
1786
1805
|
* In those cases, the promise is rejected with a
|
|
1787
1806
|
* {@link CommandProcessError | **`CommandProcessError`**}.
|
|
1788
1807
|
*
|
|
1789
1808
|
* - *Error metadata:*
|
|
1790
|
-
* - `reason` ➔ `"timeout" | "abort" | "signal" | "
|
|
1791
|
-
* - `exitCode` ➔ Exit code (if available)
|
|
1792
|
-
* - `signal` ➔ Termination signal (if any)
|
|
1793
|
-
* - `command` ➔ Executed command (plain string, no colors)
|
|
1809
|
+
* - `reason` ➔ `"timeout" | "abort" | "signal" | "validation"`
|
|
1810
|
+
* - `exitCode` ➔ Exit code (if available)
|
|
1811
|
+
* - `signal` ➔ Termination signal (if any)
|
|
1812
|
+
* - `command` ➔ Executed command (plain string, no colors)
|
|
1794
1813
|
*
|
|
1795
1814
|
* - *Type narrowing:*
|
|
1796
|
-
* - Use `instanceof CommandProcessError` to safely access metadata
|
|
1797
|
-
* - Or use {@link isCommandProcessError | **`isCommandProcessError`**} as a type guard
|
|
1815
|
+
* - Use `instanceof CommandProcessError` to safely access metadata
|
|
1816
|
+
* - Or use {@link isCommandProcessError | **`isCommandProcessError`**} as a type guard
|
|
1798
1817
|
*
|
|
1799
1818
|
* - *Notes:*
|
|
1800
|
-
* -
|
|
1801
|
-
* - Metadata is available programmatically (e.g. `err.reason`)
|
|
1819
|
+
* - Non-zero exit codes are NOT treated as errors
|
|
1820
|
+
* - Metadata is available programmatically (e.g. `err.reason`)
|
|
1802
1821
|
* - Metadata is also included in the formatted stack output
|
|
1803
|
-
* for CLI readability
|
|
1822
|
+
* for CLI readability
|
|
1804
1823
|
*
|
|
1805
1824
|
* @example
|
|
1806
1825
|
* ```ts
|
|
@@ -1824,6 +1843,7 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1824
1843
|
* }
|
|
1825
1844
|
* ```
|
|
1826
1845
|
* ----------------------------------------------------------------
|
|
1846
|
+
*
|
|
1827
1847
|
* @example
|
|
1828
1848
|
* ```ts
|
|
1829
1849
|
* const result = await runCommandCapture("node", ["--version"]);
|
|
@@ -1853,28 +1873,29 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1853
1873
|
*
|
|
1854
1874
|
* @remarks
|
|
1855
1875
|
* - **Execution model:**
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
1876
|
+
* - Uses {@link spawn | **`spawn`**} to avoid output size limits
|
|
1877
|
+
* imposed by `exec`
|
|
1858
1878
|
*
|
|
1859
1879
|
* - **Output handling:**
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
1880
|
+
* - Always uses `stdio: "pipe"` (cannot be overridden)
|
|
1881
|
+
* - Output is buffered entirely in memory
|
|
1862
1882
|
*
|
|
1863
1883
|
* - **Exit behavior:**
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1884
|
+
* - Does NOT reject on non-zero exit codes
|
|
1885
|
+
* - Use `result.ok` or `result.exitCode` to handle failures
|
|
1866
1886
|
*
|
|
1867
1887
|
* - **Shell execution:**
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1888
|
+
* - Defaults to `shell: true` for cross-platform compatibility
|
|
1889
|
+
* - However, shell operators and advanced shell syntax are NOT supported
|
|
1890
|
+
* - This utility always executes a single command only
|
|
1870
1891
|
*
|
|
1871
1892
|
* - **Abort & timeout:**
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1893
|
+
* - Abort signals and timeouts will terminate the process
|
|
1894
|
+
* and reject the promise
|
|
1874
1895
|
*
|
|
1875
1896
|
* - **When NOT to use this utility:**
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1897
|
+
* - When output needs to be streamed in real-time
|
|
1898
|
+
* - When handling very large outputs (risk of high memory usage)
|
|
1878
1899
|
*
|
|
1879
1900
|
* ***In those cases, use {@link runCommand | `runCommand`}.***
|
|
1880
1901
|
*/
|
|
@@ -1909,6 +1930,18 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
1909
1930
|
* - CLI tooling.
|
|
1910
1931
|
* - Long-running tasks (bundlers, compilers, CSS processors).
|
|
1911
1932
|
*
|
|
1933
|
+
* ----------------------------------------------------------------
|
|
1934
|
+
* #### Limitations
|
|
1935
|
+
*
|
|
1936
|
+
* - Only a **single command** is supported.
|
|
1937
|
+
* - Shell syntax is **NOT allowed**, including:
|
|
1938
|
+
* - `&&`, `||`
|
|
1939
|
+
* - `|`
|
|
1940
|
+
* - `>`, `<`
|
|
1941
|
+
* - command chaining or piping of any kind
|
|
1942
|
+
*
|
|
1943
|
+
* Commands must represent a single executable with arguments.
|
|
1944
|
+
*
|
|
1912
1945
|
* @param {string} command
|
|
1913
1946
|
* The executable or command to run.
|
|
1914
1947
|
*
|
|
@@ -1929,13 +1962,13 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
1929
1962
|
* {@link CommandProcessError | **`CommandProcessError`**}.
|
|
1930
1963
|
*
|
|
1931
1964
|
* - *Error metadata:*
|
|
1932
|
-
* - `reason` ➔ `"timeout" | "abort" | "signal" | "non-zero exit code"`.
|
|
1965
|
+
* - `reason` ➔ `"timeout" | "abort" | "signal" | "non-zero exit code" | "validation"`.
|
|
1933
1966
|
* - `exitCode` ➔ Exit code (if available).
|
|
1934
1967
|
* - `signal` ➔ Termination signal (if any).
|
|
1935
1968
|
* - `command` ➔ Executed command (plain string, no colors).
|
|
1936
1969
|
*
|
|
1937
1970
|
* - *Type narrowing:*
|
|
1938
|
-
* - Use
|
|
1971
|
+
* - Use ***instanceof {@link CommandProcessError | **`CommandProcessError`**}*** to safely access metadata.
|
|
1939
1972
|
* - Or use {@link isCommandProcessError | **`isCommandProcessError`**} as a type guard.
|
|
1940
1973
|
*
|
|
1941
1974
|
* - *Notes:*
|
|
@@ -1966,6 +1999,7 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
1966
1999
|
* }
|
|
1967
2000
|
* }
|
|
1968
2001
|
* ```
|
|
2002
|
+
*
|
|
1969
2003
|
* ----------------------------------------------------------------
|
|
1970
2004
|
*
|
|
1971
2005
|
* @example
|
|
@@ -2007,11 +2041,10 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
2007
2041
|
* - If `stdio` is overridden (e.g. `"pipe"`), output will NOT be auto-forwarded.
|
|
2008
2042
|
*
|
|
2009
2043
|
* - **Shell execution:**
|
|
2010
|
-
* - Defaults to {@link RunCommandOptions.shell | **`shell: true`**}
|
|
2011
|
-
*
|
|
2012
|
-
* -
|
|
2013
|
-
*
|
|
2014
|
-
* - A directly executable binary.
|
|
2044
|
+
* - Defaults to {@link RunCommandOptions.shell | **`shell: true`**}
|
|
2045
|
+
* for cross-platform compatibility (especially on Windows).
|
|
2046
|
+
* - However, shell operators and advanced shell syntax are **NOT supported**.
|
|
2047
|
+
* - This utility always executes a **single command only**.
|
|
2015
2048
|
*
|
|
2016
2049
|
* - **Abort handling:**
|
|
2017
2050
|
* - When `signal` is provided, the process will be terminated
|
|
@@ -2031,9 +2064,9 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
2031
2064
|
*
|
|
2032
2065
|
* - **When NOT to use this utility:**
|
|
2033
2066
|
* - When you need to capture output programmatically.
|
|
2034
|
-
* - When you need advanced shell features (`|`, `>`,
|
|
2067
|
+
* - When you need advanced shell features (`|`, `>`, `&&`, piping, chaining).
|
|
2035
2068
|
*
|
|
2036
|
-
* ***In those cases,
|
|
2069
|
+
* ***In those cases, use `exec` or a dedicated shell runner instead.***
|
|
2037
2070
|
*/
|
|
2038
2071
|
declare function runCommand(command: string, args: readonly string[]): Promise<ChildProcess>;
|
|
2039
2072
|
declare function runCommand(command: string, options: RunCommandOptions): Promise<ChildProcess>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.11`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-
|
|
12
|
-
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-
|
|
13
|
-
import { t as CommandIdentity } from "./index-
|
|
14
|
-
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-
|
|
11
|
+
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-BleSbKJp.js";
|
|
12
|
+
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-CwHGSras.js";
|
|
13
|
+
import { t as CommandIdentity } from "./index-NLQcJJFO.js";
|
|
14
|
+
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-DnV58KJc.js";
|
|
15
15
|
import { ChildProcess, SpawnOptions, StdioOptions, spawn } from "node:child_process";
|
|
16
16
|
import * as acorn from "acorn";
|
|
17
17
|
|
|
@@ -1464,7 +1464,7 @@ type BaseRunCommandOptions = {
|
|
|
1464
1464
|
*/
|
|
1465
1465
|
env?: NodeJS.ProcessEnv;
|
|
1466
1466
|
/** ----------------------------------------------------------------
|
|
1467
|
-
* * ***
|
|
1467
|
+
* * ***Control whether the command is executed inside a system shell.***
|
|
1468
1468
|
* ----------------------------------------------------------------
|
|
1469
1469
|
*
|
|
1470
1470
|
* By default, commands are executed inside a system shell:
|
|
@@ -1474,13 +1474,18 @@ type BaseRunCommandOptions = {
|
|
|
1474
1474
|
* Set this option to `false` to bypass the shell and execute
|
|
1475
1475
|
* the command directly.
|
|
1476
1476
|
*
|
|
1477
|
-
* This is useful for:
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1477
|
+
* - This is useful for:
|
|
1478
|
+
* - Strict argument handling.
|
|
1479
|
+
* - Avoiding shell interpretation.
|
|
1480
|
+
*
|
|
1481
|
+
* - ⚠️ Note:
|
|
1482
|
+
* - Shell operators and advanced shell syntax (e.g. `&&`, `||`, `|`, `>`)
|
|
1483
|
+
* are **not supported**, regardless of this option.
|
|
1484
|
+
* - This utility always executes a single command with arguments.
|
|
1480
1485
|
*
|
|
1481
1486
|
* @default true (shell is enabled)
|
|
1482
1487
|
*/
|
|
1483
|
-
shell?:
|
|
1488
|
+
shell?: boolean;
|
|
1484
1489
|
/** ----------------------------------------------------------------
|
|
1485
1490
|
* * ***Abort signal for cancelling the spawned process.***
|
|
1486
1491
|
* ----------------------------------------------------------------
|
|
@@ -1552,6 +1557,7 @@ type BaseRunCommandOptions = {
|
|
|
1552
1557
|
*/
|
|
1553
1558
|
useColors?: boolean;
|
|
1554
1559
|
} & Omit<SpawnOptions, "cwd" | "env" | "shell" | "stdio" | "argv0" | "timeout">;
|
|
1560
|
+
type Reason = "timeout" | "abort" | "signal" | "non-zero exit code" | "validation";
|
|
1555
1561
|
/** ----------------------------------------------------------------
|
|
1556
1562
|
* * ***Represents a command execution failure.***
|
|
1557
1563
|
* ----------------------------------------------------------------
|
|
@@ -1626,7 +1632,7 @@ type BaseRunCommandOptions = {
|
|
|
1626
1632
|
* output when logged via `console.error`.
|
|
1627
1633
|
*/
|
|
1628
1634
|
declare class CommandProcessError extends Error {
|
|
1629
|
-
reason:
|
|
1635
|
+
reason: Reason;
|
|
1630
1636
|
exitCode?: number;
|
|
1631
1637
|
signal?: NodeJS.Signals | null;
|
|
1632
1638
|
command: string;
|
|
@@ -1753,6 +1759,18 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1753
1759
|
* - Parsing results (JSON, text, etc.).
|
|
1754
1760
|
* - Testing and scripting utilities.
|
|
1755
1761
|
*
|
|
1762
|
+
* ----------------------------------------------------------------
|
|
1763
|
+
* #### Limitations
|
|
1764
|
+
*
|
|
1765
|
+
* - Only a **single command** is supported.
|
|
1766
|
+
* - Shell syntax is **NOT allowed**, including:
|
|
1767
|
+
* - `&&`, `||`
|
|
1768
|
+
* - `|`
|
|
1769
|
+
* - `>`, `<`
|
|
1770
|
+
* - command chaining or piping of any kind
|
|
1771
|
+
*
|
|
1772
|
+
* Commands must represent a single executable with arguments.
|
|
1773
|
+
*
|
|
1756
1774
|
* @param {string} command
|
|
1757
1775
|
* The executable or command to run.
|
|
1758
1776
|
*
|
|
@@ -1774,33 +1792,34 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1774
1792
|
*
|
|
1775
1793
|
* This function does NOT reject on non-zero exit codes.
|
|
1776
1794
|
* - Instead, use:
|
|
1777
|
-
* - `result.ok
|
|
1778
|
-
* - `result.exitCode
|
|
1795
|
+
* - `result.ok`
|
|
1796
|
+
* - `result.exitCode`
|
|
1779
1797
|
*
|
|
1780
|
-
*
|
|
1781
|
-
*
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1784
|
-
*
|
|
1798
|
+
* The promise will reject in the following cases:
|
|
1799
|
+
* - validation errors (invalid command or arguments)
|
|
1800
|
+
* - spawn errors
|
|
1801
|
+
* - abort signals
|
|
1802
|
+
* - timeouts
|
|
1803
|
+
* - termination by signal
|
|
1785
1804
|
*
|
|
1786
1805
|
* In those cases, the promise is rejected with a
|
|
1787
1806
|
* {@link CommandProcessError | **`CommandProcessError`**}.
|
|
1788
1807
|
*
|
|
1789
1808
|
* - *Error metadata:*
|
|
1790
|
-
* - `reason` ➔ `"timeout" | "abort" | "signal" | "
|
|
1791
|
-
* - `exitCode` ➔ Exit code (if available)
|
|
1792
|
-
* - `signal` ➔ Termination signal (if any)
|
|
1793
|
-
* - `command` ➔ Executed command (plain string, no colors)
|
|
1809
|
+
* - `reason` ➔ `"timeout" | "abort" | "signal" | "validation"`
|
|
1810
|
+
* - `exitCode` ➔ Exit code (if available)
|
|
1811
|
+
* - `signal` ➔ Termination signal (if any)
|
|
1812
|
+
* - `command` ➔ Executed command (plain string, no colors)
|
|
1794
1813
|
*
|
|
1795
1814
|
* - *Type narrowing:*
|
|
1796
|
-
* - Use `instanceof CommandProcessError` to safely access metadata
|
|
1797
|
-
* - Or use {@link isCommandProcessError | **`isCommandProcessError`**} as a type guard
|
|
1815
|
+
* - Use `instanceof CommandProcessError` to safely access metadata
|
|
1816
|
+
* - Or use {@link isCommandProcessError | **`isCommandProcessError`**} as a type guard
|
|
1798
1817
|
*
|
|
1799
1818
|
* - *Notes:*
|
|
1800
|
-
* -
|
|
1801
|
-
* - Metadata is available programmatically (e.g. `err.reason`)
|
|
1819
|
+
* - Non-zero exit codes are NOT treated as errors
|
|
1820
|
+
* - Metadata is available programmatically (e.g. `err.reason`)
|
|
1802
1821
|
* - Metadata is also included in the formatted stack output
|
|
1803
|
-
* for CLI readability
|
|
1822
|
+
* for CLI readability
|
|
1804
1823
|
*
|
|
1805
1824
|
* @example
|
|
1806
1825
|
* ```ts
|
|
@@ -1824,6 +1843,7 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1824
1843
|
* }
|
|
1825
1844
|
* ```
|
|
1826
1845
|
* ----------------------------------------------------------------
|
|
1846
|
+
*
|
|
1827
1847
|
* @example
|
|
1828
1848
|
* ```ts
|
|
1829
1849
|
* const result = await runCommandCapture("node", ["--version"]);
|
|
@@ -1853,28 +1873,29 @@ type RunCommandCaptureOptions = Omit<BaseRunCommandOptions, "stdio">;
|
|
|
1853
1873
|
*
|
|
1854
1874
|
* @remarks
|
|
1855
1875
|
* - **Execution model:**
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
1876
|
+
* - Uses {@link spawn | **`spawn`**} to avoid output size limits
|
|
1877
|
+
* imposed by `exec`
|
|
1858
1878
|
*
|
|
1859
1879
|
* - **Output handling:**
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
1880
|
+
* - Always uses `stdio: "pipe"` (cannot be overridden)
|
|
1881
|
+
* - Output is buffered entirely in memory
|
|
1862
1882
|
*
|
|
1863
1883
|
* - **Exit behavior:**
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1884
|
+
* - Does NOT reject on non-zero exit codes
|
|
1885
|
+
* - Use `result.ok` or `result.exitCode` to handle failures
|
|
1866
1886
|
*
|
|
1867
1887
|
* - **Shell execution:**
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1888
|
+
* - Defaults to `shell: true` for cross-platform compatibility
|
|
1889
|
+
* - However, shell operators and advanced shell syntax are NOT supported
|
|
1890
|
+
* - This utility always executes a single command only
|
|
1870
1891
|
*
|
|
1871
1892
|
* - **Abort & timeout:**
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1893
|
+
* - Abort signals and timeouts will terminate the process
|
|
1894
|
+
* and reject the promise
|
|
1874
1895
|
*
|
|
1875
1896
|
* - **When NOT to use this utility:**
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1897
|
+
* - When output needs to be streamed in real-time
|
|
1898
|
+
* - When handling very large outputs (risk of high memory usage)
|
|
1878
1899
|
*
|
|
1879
1900
|
* ***In those cases, use {@link runCommand | `runCommand`}.***
|
|
1880
1901
|
*/
|
|
@@ -1909,6 +1930,18 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
1909
1930
|
* - CLI tooling.
|
|
1910
1931
|
* - Long-running tasks (bundlers, compilers, CSS processors).
|
|
1911
1932
|
*
|
|
1933
|
+
* ----------------------------------------------------------------
|
|
1934
|
+
* #### Limitations
|
|
1935
|
+
*
|
|
1936
|
+
* - Only a **single command** is supported.
|
|
1937
|
+
* - Shell syntax is **NOT allowed**, including:
|
|
1938
|
+
* - `&&`, `||`
|
|
1939
|
+
* - `|`
|
|
1940
|
+
* - `>`, `<`
|
|
1941
|
+
* - command chaining or piping of any kind
|
|
1942
|
+
*
|
|
1943
|
+
* Commands must represent a single executable with arguments.
|
|
1944
|
+
*
|
|
1912
1945
|
* @param {string} command
|
|
1913
1946
|
* The executable or command to run.
|
|
1914
1947
|
*
|
|
@@ -1929,13 +1962,13 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
1929
1962
|
* {@link CommandProcessError | **`CommandProcessError`**}.
|
|
1930
1963
|
*
|
|
1931
1964
|
* - *Error metadata:*
|
|
1932
|
-
* - `reason` ➔ `"timeout" | "abort" | "signal" | "non-zero exit code"`.
|
|
1965
|
+
* - `reason` ➔ `"timeout" | "abort" | "signal" | "non-zero exit code" | "validation"`.
|
|
1933
1966
|
* - `exitCode` ➔ Exit code (if available).
|
|
1934
1967
|
* - `signal` ➔ Termination signal (if any).
|
|
1935
1968
|
* - `command` ➔ Executed command (plain string, no colors).
|
|
1936
1969
|
*
|
|
1937
1970
|
* - *Type narrowing:*
|
|
1938
|
-
* - Use
|
|
1971
|
+
* - Use ***instanceof {@link CommandProcessError | **`CommandProcessError`**}*** to safely access metadata.
|
|
1939
1972
|
* - Or use {@link isCommandProcessError | **`isCommandProcessError`**} as a type guard.
|
|
1940
1973
|
*
|
|
1941
1974
|
* - *Notes:*
|
|
@@ -1966,6 +1999,7 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
1966
1999
|
* }
|
|
1967
2000
|
* }
|
|
1968
2001
|
* ```
|
|
2002
|
+
*
|
|
1969
2003
|
* ----------------------------------------------------------------
|
|
1970
2004
|
*
|
|
1971
2005
|
* @example
|
|
@@ -2007,11 +2041,10 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
2007
2041
|
* - If `stdio` is overridden (e.g. `"pipe"`), output will NOT be auto-forwarded.
|
|
2008
2042
|
*
|
|
2009
2043
|
* - **Shell execution:**
|
|
2010
|
-
* - Defaults to {@link RunCommandOptions.shell | **`shell: true`**}
|
|
2011
|
-
*
|
|
2012
|
-
* -
|
|
2013
|
-
*
|
|
2014
|
-
* - A directly executable binary.
|
|
2044
|
+
* - Defaults to {@link RunCommandOptions.shell | **`shell: true`**}
|
|
2045
|
+
* for cross-platform compatibility (especially on Windows).
|
|
2046
|
+
* - However, shell operators and advanced shell syntax are **NOT supported**.
|
|
2047
|
+
* - This utility always executes a **single command only**.
|
|
2015
2048
|
*
|
|
2016
2049
|
* - **Abort handling:**
|
|
2017
2050
|
* - When `signal` is provided, the process will be terminated
|
|
@@ -2031,9 +2064,9 @@ type RunCommandOptions = BaseRunCommandOptions;
|
|
|
2031
2064
|
*
|
|
2032
2065
|
* - **When NOT to use this utility:**
|
|
2033
2066
|
* - When you need to capture output programmatically.
|
|
2034
|
-
* - When you need advanced shell features (`|`, `>`,
|
|
2067
|
+
* - When you need advanced shell features (`|`, `>`, `&&`, piping, chaining).
|
|
2035
2068
|
*
|
|
2036
|
-
* ***In those cases,
|
|
2069
|
+
* ***In those cases, use `exec` or a dedicated shell runner instead.***
|
|
2037
2070
|
*/
|
|
2038
2071
|
declare function runCommand(command: string, args: readonly string[]): Promise<ChildProcess>;
|
|
2039
2072
|
declare function runCommand(command: string, options: RunCommandOptions): Promise<ChildProcess>;
|