class FswatchDriver extends AbstractDriver

Properties

protected Channel|null $stopSignal from  AbstractDriver
protected bool $stopping from  AbstractDriver
protected mixed $process
protected array<int, resource> $pipes

Methods

__construct(Option $option)

No description

bool
isDarwin()

Determine if the current OS is macOS.

void
stop()

Stop the fswatch process.

void
watchAtInterval(float $seconds, callable $scan)

Run a polling scan until the driver is stopped.

array
resolveTargets(array $watchPaths)

Resolve configured watch paths to absolute targets.

array
existingTargets(array $targets)

Filter targets that currently exist.

array
exec(string $command)

Execute a shell command using Swoole's coroutine-aware exec.

string
shellArguments(array $arguments)

Escape a list of arguments for interpolation into a shell command.

void
watch(Channel $channel)

Watch for file changes using fswatch.

void
processOutput(string $buffer, string $chunk, Channel $channel, string $basePath, array $watchPaths, bool $final = false)

Process complete newline-delimited paths while retaining a partial tail.

void
openProcess()

Open the fswatch subprocess and retain its pipes.

bool
shouldStopWatching(Channel $channel)

Determine whether the active watch loop should stop.

array
getCommand()

Build the fswatch command arguments.

Details

at line 20
__construct(Option $option)

No description

Parameters

Option $option

in AbstractDriver at line 26
bool isDarwin()

Determine if the current OS is macOS.

Return Value

bool

at line 123
void stop()

Stop the fswatch process.

Return Value

void

in AbstractDriver at line 47
protected void watchAtInterval(float $seconds, callable $scan)

Run a polling scan until the driver is stopped.

Parameters

float $seconds
callable $scan

Return Value

void

in AbstractDriver at line 80
protected array resolveTargets(array $watchPaths)

Resolve configured watch paths to absolute targets.

Parameters

array $watchPaths

Return Value

array

in AbstractDriver at line 100
protected array existingTargets(array $targets)

Filter targets that currently exist.

Parameters

array $targets

Return Value

array

in AbstractDriver at line 112
protected array exec(string $command)

Execute a shell command using Swoole's coroutine-aware exec.

Every interpolated argument must be escaped before it reaches this boundary.

Parameters

string $command

Return Value

array

in AbstractDriver at line 128
protected string shellArguments(array $arguments)

Escape a list of arguments for interpolation into a shell command.

Parameters

array $arguments

Return Value

string

at line 32
void watch(Channel $channel)

Watch for file changes using fswatch.

Parameters

Channel $channel

Return Value

void

at line 88
protected void processOutput(string $buffer, string $chunk, Channel $channel, string $basePath, array $watchPaths, bool $final = false)

Process complete newline-delimited paths while retaining a partial tail.

Parameters

string $buffer
string $chunk
Channel $channel
string $basePath
array $watchPaths
bool $final

Return Value

void

at line 150
protected void openProcess()

Open the fswatch subprocess and retain its pipes.

Return Value

void

at line 169
protected bool shouldStopWatching(Channel $channel)

Determine whether the active watch loop should stop.

The state may change while hooked I/O yields to another coroutine.

Parameters

Channel $channel

Return Value

bool

at line 179
protected array getCommand()

Build the fswatch command arguments.

Return Value

array