code: protected function getScriptListeners(Event $event)
      {
          $package = $this->composer->getPackage();
          $scripts = $package->getScripts();
  
          if (empty($scripts[$event->getName()])) {
              return array();
          }
  
          if ($this->loader) {
              $this->loader->unregister();
          }
  
          $generator = $this->composer->getAutoloadGenerator();
          if ($event instanceof ScriptEvent) {
              $generator->setDevMode($event->isDevMode());
          }
  
          $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
          $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
          $map = $generator->parseAutoloads($packageMap, $package);
          $this->loader = $generator->createLoader($map);
          $this->loader->register();
  
          return $scripts[$event->getName()];
      }
docs: Finds all listeners defined as scripts in the package
  
  @param  Event $event Event object
  @return array Listeners