Process utility library for Hack
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src
test
.editorconfig
.gitattributes
.gitignore
.hhconfig
.travis.yml
Dockerfile
LICENSE
README.md
composer.json
composer.lock
docker-compose.yml
hh_autoload.json
hhtool

README.md

process

Latest Stable Version Build Status Dependency Status License

Basic usage

Start the process, it is an example to wait until the end.
information of stdout and stderr are output to the buffer.

use HHPack\Process;

async function main() : Awaitable<void>
{
  $result = await Process\exec('hh_client restart');
  $result->stdout()->display();
  $result->stderr()->display();

  $result = await Process\exec('hh_client check --json');
  $result->display();
}

main();

Execution of the script

If you want to run the script, you can run in execFile function.

use HHPack\Process;

async function main() : Awaitable<void>
{
  $result = await Process\execFile('/path/to/example.hh', [ 'a', 'b' ]);
  $result->stdout()->display();
  $result->stderr()->display();
}

main();

Manual control of the process

You can use the spawn function to generate a new child process.
To wait for the generated child process to finish use the wait method.

use HHPack\Process;
use HHPack\Process\ProcessOptions;

async function pipe_example() : Awaitable<void>
{
  $options = new ProcessOptions();
  $options->stdout(new Stdout());
  $options->stderr(new Stderr());

  using ($p = Process\spawn('hh_client restart', [], $options)) {
    await $p->wait();
  }
}

pipe_example();

Run the test

You can run the test with the following command.

composer install
composer test