You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/typescript.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
## Available types
10
10
11
-
The following types can be imported: [`ResultPromise`](api.md#return-value), [`Subprocess`](api.md#subprocess), [`Result`](api.md#result), [`ExecaError`](api.md#execaerror), [`Options`](api.md#options), [`StdinOption`](api.md#optionsstdin) and [`StdoutStderrOption`](api.md#optionsstdout).
11
+
The following types can be imported: [`ResultPromise`](api.md#return-value), [`Subprocess`](api.md#subprocess), [`Result`](api.md#result), [`ExecaError`](api.md#execaerror), [`Options`](api.md#options), [`StdinOption`](api.md#optionsstdin), [`StdoutStderrOption`](api.md#optionsstdout) and [`TemplateExpression`](api.md#execacommand).
12
12
13
13
```ts
14
14
import {
@@ -19,6 +19,7 @@ import {
19
19
typeOptions,
20
20
typeStdinOption,
21
21
typeStdoutStderrOption,
22
+
typeTemplateExpression,
22
23
} from'execa';
23
24
24
25
const options:Options= {
@@ -27,9 +28,10 @@ const options: Options = {
27
28
stderr: 'pipe'satisfiesStdoutStderrOption,
28
29
timeout: 1000,
29
30
};
31
+
const task:TemplateExpression='build';
30
32
31
33
try {
32
-
const subprocess:ResultPromise=execa(options)`npm run build`;
34
+
const subprocess:ResultPromise=execa(options)`npm run ${task}`;
33
35
const result:Result=awaitsubprocess;
34
36
console.log(result.stdout);
35
37
} catch (error) {
@@ -41,7 +43,7 @@ try {
41
43
42
44
## Synchronous execution
43
45
44
-
Their [synchronous](#synchronous-execution) counterparts are [`SyncResult`](api.md#result), [`ExecaSyncError`](api.md#execasyncerror), [`SyncOptions`](api.md#options), [`StdinSyncOption`](api.md#optionsstdin) and [`StdoutStderrSyncOption`](api.md#optionsstdout).
46
+
Their [synchronous](#synchronous-execution) counterparts are [`SyncResult`](api.md#result), [`ExecaSyncError`](api.md#execasyncerror), [`SyncOptions`](api.md#options), [`StdinSyncOption`](api.md#optionsstdin), [`StdoutStderrSyncOption`](api.md#optionsstdout) and [`TemplateExpression`](api.md#execacommand).
45
47
46
48
```ts
47
49
import {
@@ -51,6 +53,7 @@ import {
51
53
typeSyncOptions,
52
54
typeStdinSyncOption,
53
55
typeStdoutStderrSyncOption,
56
+
typeTemplateExpression,
54
57
} from'execa';
55
58
56
59
const options:SyncOptions= {
@@ -59,9 +62,10 @@ const options: SyncOptions = {
59
62
stderr: 'pipe'satisfiesStdoutStderrSyncOption,
60
63
timeout: 1000,
61
64
};
65
+
const task:TemplateExpression='build';
62
66
63
67
try {
64
-
const result:SyncResult=execaSync(options)`npm run build`;
68
+
const result:SyncResult=execaSync(options)`npm run ${task}`;
65
69
console.log(result.stdout);
66
70
} catch (error) {
67
71
if (errorinstanceofExecaSyncError) {
@@ -91,9 +95,10 @@ const options = {
91
95
stderr: 'pipe',
92
96
timeout: 1000,
93
97
} asconst;
98
+
const task ='build';
94
99
95
100
try {
96
-
const subprocess =execa(options)`npm run build`;
101
+
const subprocess =execa(options)`npm run ${task}`;
0 commit comments