Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Dump namespace to composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Aug 26, 2018
1 parent cc3f93c commit 0b65d54
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->createPackage($config);
$this->initComposer($config);
$this->setNamespace($config);

$output->writeln(\sprintf('<info>Package %s created in: </info><comment>%s</comment>', $this->info['PACKAGE_NAME'], $directory));
}
Expand Down Expand Up @@ -200,6 +201,20 @@ protected function createPackage(array $config)
return $this->packageDirectory;
}

public function setNamespace(array $config)
{
$composerJson = $this->packageDirectory.'/composer.json';
$composer = \json_decode(\file_get_contents($composerJson));

$composer->autoload = [
'psr-4' => [
$this->info['NAMESPACE'].'\\' => 'src',
],
];

\file_put_contents($composerJson, \json_encode($composer, \JSON_PRETTY_PRINT|\JSON_UNESCAPED_UNICODE));
}

/**
* @param string $string
*
Expand Down

0 comments on commit 0b65d54

Please sign in to comment.