Browse Source

don't display dev expiration time warning when running self-update command

Sergey Linnik 12 years ago
parent
commit
2448c5a7c2
2 changed files with 9 additions and 4 deletions
  1. 3 4
      src/Composer/Compiler.php
  2. 6 0
      src/Composer/Console/Application.php

+ 3 - 4
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();

+ 6 - 0
src/Composer/Console/Application.php

@@ -77,6 +77,12 @@ class Application extends BaseApplication
             $output->writeln('<warning>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.</warning>');
         }
 
+        if (defined('COMPOSER_DEV_WARNING_TIME') && $this->getCommandName($input) !== 'self-update') {
+            if (time() > COMPOSER_DEV_WARNING_TIME) {
+                $output->writeln(sprintf('<warning>This dev build of composer is outdated, please run "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
+            }
+        }
+
         return parent::doRun($input, $output);
     }