protected function _load()
{
return Filter::on($this, 'load', [], function ($chain) {
$specDirs = $this->commandLine()->get('spec');
foreach ($specDirs as $dir) {
if (!file_exists($dir)) {
fwrite(STDERR, "ERROR: unexisting `{$dir}` directory, use --spec option to set a valid one (ex: --spec=tests).\n");
exit(-1);
}
}
$files = Dir::scan($specDirs, ['include' => $this->commandLine()->get('pattern'), 'exclude' => '*/.*', 'type' => 'file']);
foreach ($files as $file) {
require $file;
}
});
}