Sha256: 6f7615493725f81cfcec3652c224b4955ad62682c8cd344697cf078259720c98

Contents?: true

Size: 1.89 KB

Versions: 24

Compression:

Stored size: 1.89 KB

Contents

<?php

/*
 * This file is part of Composer.
 *
 * (c) Nils Adermann <naderman@naderman.de>
 *     Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Command;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * @author Jordi Boggiano <j.boggiano@seld.be>
 */
class ScriptAliasCommand extends BaseCommand
{
    private $script;
    private $description;

    public function __construct($script, $description)
    {
        $this->script = $script;
        $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;

        parent::__construct();
    }

    protected function configure()
    {
        $this
            ->setName($this->script)
            ->setDescription($this->description)
            ->setDefinition(array(
                new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
                new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
                new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
            ))
            ->setHelp(
                <<<EOT
The <info>run-script</info> command runs scripts defined in composer.json:

<info>php composer.phar run-script post-update-cmd</info>
EOT
            )
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $composer = $this->getComposer();

        $args = $input->getArguments();

        return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
    }
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
dependabot-composer-0.106.12 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.106.11 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.106.5 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.100.2 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.36 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.19 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.13 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.11 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.10 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.7 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.6 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.98.1 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.70 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.63 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.60 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.52 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.50 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.47 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.42 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php
dependabot-composer-0.95.40 helpers/vendor/composer/composer/src/Composer/Command/ScriptAliasCommand.php