Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #103 #104

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/Plugin.php
Expand Up @@ -41,6 +41,7 @@ class Plugin implements PluginInterface, EventSubscriberInterface
'The value of "%s" (in the composer.json "extra".section) must be an integer larger then %d, %s given.';
const MESSAGE_NOT_INSTALLED = 'PHPCodeSniffer is not installed';
const MESSAGE_NOTHING_TO_INSTALL = 'Nothing to install or update';
const MESSAGE_PLUGIN_UNINSTALLED = 'PHPCodeSniffer Composer Installer is uninstalled';
const MESSAGE_RUNNING_INSTALLER = 'Running PHPCodeSniffer Composer Installer';

const PACKAGE_NAME = 'squizlabs/php_codesniffer';
Expand All @@ -49,6 +50,8 @@ class Plugin implements PluginInterface, EventSubscriberInterface
const PHPCS_CONFIG_REGEX = '`%s:[^\r\n]+`';
const PHPCS_CONFIG_KEY = 'installed_paths';

const PLUGIN_NAME = 'dealerdirect/phpcodesniffer-composer-installer';

/**
* @var Composer
*/
Expand Down Expand Up @@ -182,9 +185,24 @@ public function onDependenciesChangedEvent()
$io->write(sprintf('<info>%s</info>', self::MESSAGE_NOTHING_TO_INSTALL));
}
} else {
$exitCode = 1;
if ($isVerbose) {
$io->write(sprintf('<info>%s</info>', self::MESSAGE_NOT_INSTALLED));
$pluginPackage = $this
->composer
->getRepositoryManager()
->getLocalRepository()
->findPackages(self::PLUGIN_NAME)
;

$isPluginUninstalled = count($pluginPackage) === 0;

if ($isPluginUninstalled) {
if ($isVerbose) {
$io->write(sprintf('<info>%s</info>', self::MESSAGE_PLUGIN_UNINSTALLED));
}
} else {
$exitCode = 1;
if ($isVerbose) {
$io->write(sprintf('<error>%s</error>', self::MESSAGE_NOT_INSTALLED));
}
}
}

Expand Down