Script.fromComponents constructor
- String name,
- FutureOr<
ScriptComponents> callback(), { - bool onSignal(
- ProcessSignal signal
Creates a script from existing stdin, stdout, stderr, and exitCode objects encapsulated in a ScriptComponents.
This takes a callback
rather than taking a bunch of arguments directly
for two reasons:
-
If there's an error while starting the script, it's handled automatically the same way an error emitted by exitCode would be.
-
If there's a reason the script shouldn't even start loading (such as being called in a Script.capture block that's already exited), this will throw an error before even running
callback
.
This constructor should generally be avoided outside library code. Script authors are expected to primarily use Script and Script.capture.
The callback
can't be interrupted by calling kill, but the onSignal
callback allows capturing those signals so the callback may react
appropriately. When no onSignal
handler was set, calling kill will do
nothing and return false
.
Implementation
Script.fromComponents(String name, FutureOr<ScriptComponents> callback(),
{bool onSignal(ProcessSignal signal)?})
: this.fromComponentsInternal(name, callback, onSignal ?? (_) => false,
silenceStartMessage: false);