Skip to content

Commit

Permalink
composer コマンドに、dir オプションを追加
Browse files Browse the repository at this point in the history
テストも追加
  • Loading branch information
ryuring committed Jun 16, 2024
1 parent 00a59ac commit 8771414
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plugins/baser-core/src/Command/ComposerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser):
'help' => __d('baser_core', 'データベース接続名'),
'default' => 'php'
]);
$parser->addOption('dir', [
'help' => __d('baser_core', '実行対象ディレクトリ'),
'default' => ''
]);
return $parser;
}

Expand All @@ -60,23 +64,24 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser):
public function execute(Arguments $args, ConsoleIo $io)
{
try {
BcComposer::setup($args->getOption('php'));
BcComposer::setup($args->getOption('php'), $args->getOption('dir'));
} catch (\Throwable $e) {
$message = __d('baser_core', 'Composer によるアップデートが失敗しました。');
$this->log($message, LogLevel::ERROR, 'update');
$this->log($e->getMessage(), LogLevel::ERROR, 'update');
$io->out($message);
exit(1);
$io->error($message);
$this->abort();
}
BcComposer::clearCache();
$result = BcComposer::require('baser-core', $args->getArgument('version'));
if($result['code'] === 0) {
$io->out(__d('baser_core', 'Composer によるアップデートが完了しました。'));
} else {
$message = __d('baser_core', 'Composer によるアップデートが失敗しました。update ログを確認してください。');
$this->log($message, LogLevel::ERROR, 'update');
$this->log(implode("\n", $result['out']), LogLevel::ERROR, 'update');
$io->out($message);
exit(1);
$io->error($message);
$this->abort();
}
}

Expand Down

0 comments on commit 8771414

Please sign in to comment.