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/api.md
+82-2Lines changed: 82 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1033,12 +1033,14 @@ More info [here](ipc.md#send-an-initial-message) and [there](input.md#any-input-
1033
1033
1034
1034
### options.verbose
1035
1035
1036
-
_Type:_`'none' | 'short' | 'full'`\
1036
+
_Type:_`'none' | 'short' | 'full' | Function`\
1037
1037
_Default:_`'none'`
1038
1038
1039
1039
If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.
1040
1040
1041
-
If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and [IPC messages](ipc.md) are also printed.
1041
+
If `verbose` is `'full'` or a function, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and [IPC messages](ipc.md) are also printed.
1042
+
1043
+
A [function](#verbose-function) can be passed to customize logging. Please see [this page](debugging.md#custom-logging) for more information.
1042
1044
1043
1045
By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).
1044
1046
@@ -1170,6 +1172,84 @@ If `false`, escapes the command arguments on Windows.
Depending on [`verboseObject.type`](#verboseobjecttype), this is:
1205
+
-`'command'`: the [`result.escapedCommand`](#resultescapedcommand)
1206
+
-`'output'`: one line from [`result.stdout`](#resultstdout) or [`result.stderr`](#resultstderr)
1207
+
-`'ipc'`: one IPC message from [`result.ipcOutput`](#resultipcoutput)
1208
+
-`'error'`: the [`error.shortMessage`](#errorshortmessage)
1209
+
-`'duration'`: the [`result.durationMs`](#resultdurationms)
1210
+
1211
+
#### verboseObject.escapedCommand
1212
+
1213
+
_Type_: `string`
1214
+
1215
+
The file and [arguments](input.md#command-arguments) that were run. This is the same as [`result.escapedCommand`](#resultescapedcommand).
1216
+
1217
+
#### verboseObject.options
1218
+
1219
+
_Type_: [`Options`](#options-1) or [`SyncOptions`](#options-1)
1220
+
1221
+
The [options](#options-1) passed to the subprocess.
1222
+
1223
+
#### verboseObject.commandId
1224
+
1225
+
_Type_: `string`
1226
+
1227
+
Serial number identifying the subprocess within the current process. It is incremented from `'0'`.
1228
+
1229
+
This is helpful when multiple subprocesses are running at the same time.
1230
+
1231
+
This is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter.
1232
+
1233
+
#### verboseObject.timestamp
1234
+
1235
+
_Type_: `Date`
1236
+
1237
+
Event date/time.
1238
+
1239
+
#### verboseObject.result
1240
+
1241
+
_Type_: [`Result`](#result), [`SyncResult`](#result) or `undefined`
1242
+
1243
+
Subprocess [result](#result).
1244
+
1245
+
This is `undefined` if [`verboseObject.type`](#verboseobjecttype) is `'command'`, `'output'` or `'ipc'`.
1246
+
1247
+
#### verboseObject.piped
1248
+
1249
+
_Type_: `boolean`
1250
+
1251
+
Whether another subprocess is [piped](pipe.md) into this subprocess. This is `false` when [`result.pipedFrom`](#resultfailed) is empty.
1252
+
1173
1253
## Transform options
1174
1254
1175
1255
A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.
The [`verbose`](api.md#optionsverbose) option can be a function to customize logging.
114
+
115
+
It is called once per log line. The first argument is the default log line string. The second argument is the same information but as an object instead (documented [here](api.md#verbose-object)).
116
+
117
+
If a string is returned, it is printed on `stderr`. If `undefined` is returned, nothing is printed.
118
+
119
+
### Filter logs
120
+
121
+
```js
122
+
import {execaasexeca_} from'execa';
123
+
124
+
// Only print log lines showing the subprocess duration
125
+
constexeca=execa_({
126
+
verbose(verboseLine, {type}) {
127
+
return type ==='duration'? verboseLine :undefined;
Copy file name to clipboardExpand all lines: docs/typescript.md
+14-2Lines changed: 14 additions & 2 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-1), [`StdinOption`](api.md#optionsstdin), [`StdoutStderrOption`](api.md#optionsstdout), [`TemplateExpression`](api.md#execacommand), [`Message`](api.md#subprocesssendmessagemessage-sendmessageoptions), [`ExecaMethod`](api.md#execaoptions), [`ExecaNodeMethod`](api.md#execanodeoptions) and [`ExecaScriptMethod`](api.md#options).
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-1), [`StdinOption`](api.md#optionsstdin), [`StdoutStderrOption`](api.md#optionsstdout), [`TemplateExpression`](api.md#execacommand), [`Message`](api.md#subprocesssendmessagemessage-sendmessageoptions), [`VerboseObject`](api.md#verbose-object), [`ExecaMethod`](api.md#execaoptions), [`ExecaNodeMethod`](api.md#execanodeoptions) and [`ExecaScriptMethod`](api.md#options).
Their [synchronous](#synchronous-execution) counterparts are [`SyncResult`](api.md#result), [`ExecaSyncError`](api.md#execasyncerror), [`SyncOptions`](api.md#options-1), [`StdinSyncOption`](api.md#optionsstdin), [`StdoutStderrSyncOption`](api.md#optionsstdout), [`TemplateExpression`](api.md#execacommand), [`ExecaSyncMethod`](api.md#execasyncoptions) and [`ExecaScriptSyncMethod`](api.md#syncoptions).
57
+
Their [synchronous](#synchronous-execution) counterparts are [`SyncResult`](api.md#result), [`ExecaSyncError`](api.md#execasyncerror), [`SyncOptions`](api.md#options-1), [`StdinSyncOption`](api.md#optionsstdin), [`StdoutStderrSyncOption`](api.md#optionsstdout), [`TemplateExpression`](api.md#execacommand), [`SyncVerboseObject`](api.md#verbose-object), [`ExecaSyncMethod`](api.md#execasyncoptions) and [`ExecaScriptSyncMethod`](api.md#syncoptions).
0 commit comments