Skip to content

Commit

Permalink
Merge pull request #17 from danepowell/issue-16
Browse files Browse the repository at this point in the history
Fixes #16: Support Composer 2.
  • Loading branch information
zaporylie authored Oct 22, 2020
2 parents e45beee + b9d5b64 commit 4e252a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"composer-plugin-api": "^1.1"
"composer-plugin-api": "^1.1 || ^2.0"
},
"require-dev": {
"composer/composer": "^1.6",
Expand Down
15 changes: 15 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class Plugin implements PluginInterface

public function activate(Composer $composer, IOInterface $io)
{
if (version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '<=')) {
if ($io->isVerbose()) {
$io->write(sprintf('zaporylie/composer-drupal-optimizations is disabled for Composer 2'));
}
// Return early.
return;
}
// Set default version constraints based on the composer requirements.
$extra = $composer->getPackage()->getExtra();
$packages = $composer->getPackage()->getRequires();
Expand Down Expand Up @@ -54,6 +61,14 @@ public function activate(Composer $composer, IOInterface $io)
$composer->setRepositoryManager($manager);
}

public function deactivate(Composer $composer, IOInterface $io)
{
}

public function uninstall(Composer $composer, IOInterface $io)
{
}

/**
* Negotiates default require constraint and package for given drupal/core.
*
Expand Down

0 comments on commit 4e252a5

Please sign in to comment.