فهرست منبع

Check if a given event has registered any listeners. If not the script
is not defined in the composer.json file

Max Gfeller 11 سال پیش
والد
کامیت
421b09dc44
1فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 6 0
      src/Composer/Command/RunScriptCommand.php

+ 6 - 0
src/Composer/Command/RunScriptCommand.php

@@ -58,6 +58,12 @@ EOT
             }
         }
 
+        $hasListeners = $this->getComposer()->getEventDispatcher()->hasEventListeners(new \Composer\Script\CommandEvent($script, $this->getComposer(), $this->getIO()));
+
+        if(!$hasListeners) {
+            throw new \InvalidArgumentException(sprintf('Script "%s" does not exist', $script));
+        }
+
         $this->getComposer()->getEventDispatcher()->dispatchCommandEvent($script, $input->getOption('dev') || !$input->getOption('no-dev'));
     }
 }