Create wrapper around versioning library to update on builds
This commit is contained in:
@@ -31,21 +31,35 @@ class BaseCommand extends Command
|
||||
|
||||
/**
|
||||
* @param $cmd
|
||||
* @param bool $return
|
||||
* @return string
|
||||
*/
|
||||
public function runCommand($cmd)
|
||||
public function runCommand($cmd, $return=false, $verbose=true)
|
||||
{
|
||||
if (is_array($cmd))
|
||||
if (\is_array($cmd)) {
|
||||
$cmd = join(' ', $cmd);
|
||||
}
|
||||
|
||||
$this->info('Running "' . $cmd . '"');
|
||||
if($verbose) {
|
||||
$this->info('Running "' . $cmd . '"');
|
||||
}
|
||||
|
||||
$val = '';
|
||||
$process = new Process($cmd);
|
||||
$process->run(function ($type, $buffer) {
|
||||
if (Process::ERR === $type) {
|
||||
echo $buffer;
|
||||
$process->run(function ($type, $buffer) use ($return, $val) {
|
||||
if ($return) {
|
||||
$val .= $buffer;
|
||||
} else {
|
||||
echo $buffer;
|
||||
}
|
||||
|
||||
/*if (Process::ERR === $type) {
|
||||
echo $buffer;
|
||||
} else {
|
||||
echo $buffer;
|
||||
}*/
|
||||
});
|
||||
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
34
app/Console/Commands/Version.php
Normal file
34
app/Console/Commands/Version.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Version extends BaseCommand
|
||||
{
|
||||
protected $signature = 'phpvms:version {--write}';
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
* @throws \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if($this->option('write')) {
|
||||
$version_file = config_path('version.yml');
|
||||
|
||||
$cfg = Yaml::parse(file_get_contents($version_file));
|
||||
exec($cfg['git']['git-local'], $version);
|
||||
$version = substr($version[0], 0, 6);
|
||||
$cfg['build']['number'] = $version;
|
||||
|
||||
file_put_contents($version_file, Yaml::dump($cfg, 4, 2));
|
||||
}
|
||||
|
||||
$this->call('version:show', [
|
||||
'--format' => 'compact',
|
||||
'--suppress-app-name' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user