-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
run
executable file
·43 lines (36 loc) · 1.18 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env php
<?php
/**
* This script is an example of how you can use PowerProcess.
*
* Run this file followed by any command, and it will be executed via Power Process.
*
* Examples:
*
* ./run git status
* ./run ping packagist.org -c 10
* ./run cat /etc/os-release
*/
// Include autoloader
function includeIfExists(string $file): bool
{
return file_exists($file) && include $file;
}
if (
!includeIfExists(__DIR__ . '/../../autoload.php') &&
!includeIfExists(__DIR__ . '/vendor/autoload.php') &&
!includeIfExists(__DIR__ . '/../../../../vendor/autoload.php')
) {
fwrite(STDERR, 'Dependencies not found. Install with Composer.'.PHP_EOL);
exit(1);
}
// PowerProcess needs IO.
$input = new \Symfony\Component\Console\Input\ArgvInput($argv);
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
// Replace Style with your own to change the output style.
$io = new DevShop\Component\PowerProcess\PowerProcessStyle($input, $output);
// Load command from everything after the filename.
$command = array_slice($argv, 1);
$process = new DevShop\Component\PowerProcess\PowerProcess($command, $io);
$process->run();
exit($process->getExitCode());