Explorar o código

Added Ctrl+C support to create-project command for unix-like systems

Barys Biankouski %!s(int64=9) %!d(string=hai) anos
pai
achega
38bc4e6a78
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      src/Composer/Command/CreateProjectCommand.php

+ 11 - 0
src/Composer/Command/CreateProjectCommand.php

@@ -290,6 +290,17 @@ EOT
             $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
         }
 
+        // handler Ctrl+C for unix-like systems
+        if (function_exists('pcntl_signal')) {
+            declare(ticks = 100);
+            $isPcntlHandler = true;
+            pcntl_signal(SIGINT, function() use ($directory) {
+                $fs = new Filesystem();
+                $fs->removeDirectory($directory);
+                exit();
+            });
+        }
+
         $io->writeError('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>');
 
         if ($disablePlugins) {