API reference / @jsprismarine/mcfunction / RecordingCommandRunner
Class: RecordingCommandRunner<TSource>
Defined in: runner.ts:71
A runner that records what it was asked to run instead of running it. It is the second adapter at the command seam: tests and pack authors use it to check what a function would execute without a world to execute it against.
Example
const runner = new RecordingCommandRunner();
new FunctionExecutor({ functions, runner }).run('pack:greet', { source: console });
expect(runner.commandLines).toEqual(['say hello']);Type Parameters
TSource
TSource = unknown
Implements
CommandRunner<TSource>
Constructors
Constructor
new RecordingCommandRunner<
TSource>(respond?):RecordingCommandRunner<TSource>
Defined in: runner.ts:75
Parameters
respond?
(commandLine, context) => CommandOutcome
Decides what each command reports back. Everything succeeds with no forks by default.
Returns
RecordingCommandRunner<TSource>
Properties
recorded
readonlyrecorded:RecordedCommand<TSource>[] =[]
Defined in: runner.ts:73
Every command handed to the runner, in execution order.
Accessors
commandLines
Get Signature
get commandLines(): readonly
string[]
Defined in: runner.ts:87
The recorded command text, in execution order.
Returns
readonly string[]
Methods
clear()
clear():
void
Defined in: runner.ts:92
Forgets everything recorded so far.
Returns
void
run()
run(
commandLine,context):CommandOutcome
Defined in: runner.ts:81
Records the command and returns whatever the configured response says.
Parameters
commandLine
string
context
CommandContext<TSource>