From 2448c5a7c273b347d2dce568c30fb5bb31a269fa Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Sun, 24 Jun 2012 14:18:07 +0400 Subject: [PATCH] don't display dev expiration time warning when running self-update command --- src/Composer/Compiler.php | 7 +++---- src/Composer/Console/Application.php | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index d0d11d800..4712bb4a1 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -187,12 +187,11 @@ EOF; // add warning once the phar is older than 30 days if (preg_match('{^[a-f0-9]+$}', $this->version)) { - $stub .= 'if (time() > '.(time()+30*86400).') {'. - "\n echo 'This dev build of composer is outdated, please run \"'.\$argv[0].' self-update\" to get the latest.'.PHP_EOL;". - "\n}\n"; + $warningTime = time() + 30*86400; + $stub .= "define('COMPOSER_DEV_WARNING_TIME', $warningTime);\n"; } - return $stub .= <<<'EOF' + return $stub . <<<'EOF' require 'phar://composer.phar/bin/composer'; __HALT_COMPILER(); diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index e1f57d654..9aada8587 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -77,6 +77,12 @@ class Application extends BaseApplication $output->writeln('Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.'); } + if (defined('COMPOSER_DEV_WARNING_TIME') && $this->getCommandName($input) !== 'self-update') { + if (time() > COMPOSER_DEV_WARNING_TIME) { + $output->writeln(sprintf('This dev build of composer is outdated, please run "%s self-update" to get the latest version.', $_SERVER['PHP_SELF'])); + } + } + return parent::doRun($input, $output); }