From a8adbfeb9fc7861deade782938222714168a22a8 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 5 Sep 2014 17:28:50 +0100 Subject: [PATCH] Disallow overriding commands with scripts --- src/Composer/Command/RunScriptCommand.php | 6 +++--- src/Composer/Console/Application.php | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/RunScriptCommand.php b/src/Composer/Command/RunScriptCommand.php index 7f94814a7..f01a5febe 100644 --- a/src/Composer/Command/RunScriptCommand.php +++ b/src/Composer/Command/RunScriptCommand.php @@ -89,12 +89,12 @@ EOT putenv('PATH='.realpath($binDir).PATH_SEPARATOR.getenv('PATH')); } - $args = $input->getArguments(); + $args = $input->getArgument('args'); if (in_array($script, $this->commandEvents)) { - return $composer->getEventDispatcher()->dispatchCommandEvent($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']); + return $composer->getEventDispatcher()->dispatchCommandEvent($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args); } - return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']); + return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args); } } diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 524b01df3..266767d9b 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -117,7 +117,11 @@ class Application extends BaseApplication if (isset($composer['scripts']) && is_array($composer['scripts'])) { foreach ($composer['scripts'] as $script => $dummy) { if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) { - $this->add(new Command\ScriptAliasCommand($script)); + if ($this->has($script)) { + $output->writeln('A script named '.$script.' would override a native Composer function and has been skipped'); + } else { + $this->add(new Command\ScriptAliasCommand($script)); + } } } }