#!/usr/bin/env php
<?php

if (is_file($autoload = __DIR__ . '/../vendor/autoload.php')) {
    require($autoload);
} elseif (is_file($autoload = __DIR__ . '/../../../autoload.php')) {
    require($autoload);
} else {
    fwrite(STDERR,
        'You must set up the project dependencies, run the following commands:'.PHP_EOL.
        'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
        'php composer.phar install'.PHP_EOL
    );
    exit(1);
}

use React\ChildProcess\Process;
use React\EventLoop\Factory as EventFactory;

$wd = __DIR__ . '/../';

$loop = EventFactory::create();

$process = new Process('node_modules/selenium-standalone/bin/selenium-standalone start', $wd);
$process->start($loop);

$process->stdout->on('data', function($output) {
    echo $output . PHP_EOL;
});
$process->stderr->on('data', function($output) {
    echo $output . PHP_EOL;
});

$loop->run();
