Skip to content

Commit 71b0175

Browse files
author
Alex Verbruggen
authored
Add package path option. (#4272)
1 parent 0ae58aa commit 71b0175

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/Command/Generate/ComposerCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ protected function configure()
7070
InputOption::VALUE_REQUIRED,
7171
$this->trans('commands.common.options.module')
7272
)
73+
->addOption(
74+
'package-path',
75+
null,
76+
InputOption::VALUE_OPTIONAL,
77+
$this->trans('commands.generate.composer.options.package-path')
78+
)
7379
->addOption(
7480
'name',
7581
null,
@@ -377,6 +383,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
377383
}
378384

379385
$module = $input->getOption('module');
386+
$packagePath = $input->getOption('package-path');
380387
$name = $input->getOption('name');
381388
$type = $input->getOption('type');
382389
$description = $input->getOption('description');
@@ -398,6 +405,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
398405

399406
$this->generator->generate([
400407
'machine_name' => $module,
408+
'package_path' => $packagePath,
401409
'name' => $name,
402410
'type' => $type,
403411
'description' => $description,

src/Command/Generate/ModuleCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
244244
->addCommand(
245245
'generate:composer', [
246246
'--module' => $machineName,
247+
'--package-path' => $modulePath,
247248
'--name' => 'drupal/' . $machineName,
248249
'--type' => 'drupal-module',
249250
'--description' => $description,

src/Generator/ComposerGenerator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ public function __construct(
4040
public function generate(array $parameters)
4141
{
4242
$machineName = $parameters['machine_name'];
43+
$composerPath = !is_null($parameters['package_path']) ?
44+
$parameters['package_path'] . '/' . $machineName . '/composer.json' :
45+
$this->extensionManager->getModule($machineName)
46+
->getPath() . '/composer.json';
4347
$this->renderFile(
4448
'module/composer.json.twig',
45-
$this->extensionManager->getModule($machineName)
46-
->getPath() . '/composer.json',
49+
$composerPath,
4750
$parameters
4851
);
4952
}

0 commit comments

Comments
 (0)