Skip to content

Commit

Permalink
Add support for Winter modules (#481)
Browse files Browse the repository at this point in the history
* Add support for Winter modules

Refs #480

* Adds test for modules
  • Loading branch information
LukeTowers authored Mar 22, 2021
1 parent 1b94b41 commit e0be7bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Composer/Installers/WinterInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class WinterInstaller extends BaseInstaller
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'winter-module') {
return $this->inflectModuleVars($vars);
}

if ($vars['type'] === 'winter-plugin') {
return $this->inflectPluginVars($vars);
}
Expand All @@ -29,18 +33,25 @@ public function inflectPackageVars($vars)

return $vars;
}

protected function inflectModuleVars($vars)
{
$vars['name'] = preg_replace('/^wn-|-module$/', '', $vars['name']);

return $vars;
}

protected function inflectPluginVars($vars)
{
$vars['name'] = preg_replace('/^oc-|-plugin$/', '', $vars['name']);
$vars['name'] = preg_replace('/^wn-|-plugin$/', '', $vars['name']);
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);

return $vars;
}

protected function inflectThemeVars($vars)
{
$vars['name'] = preg_replace('/^oc-|-theme$/', '', $vars['name']);
$vars['name'] = preg_replace('/^wn-|-theme$/', '', $vars['name']);

return $vars;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Composer/Installers/Test/WinterInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public function packageNameInflectionProvider()
'acme',
'someothertheme',
),
// tests modules
array(
'winter-module',
'winter',
'wn-system-module',
'winter',
'system',
),
);
}
}

0 comments on commit e0be7bd

Please sign in to comment.