Skip to content
Snippets Groups Projects
Commit be7ede81 authored by jurgenhaas's avatar jurgenhaas
Browse files

docker/l3d#58 Move project settings out of composer.json

parent 3224c867
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,8 @@
namespace LakeDrops\Component\Composer;
use Composer\Json\JsonFile;
use Exception;
use Symfony\Component\Yaml\Yaml;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
......@@ -65,6 +67,7 @@ final class Config {
$this->init();
$this->merge($default_values, []);
$this->migrateFomrComposerJson();
}
/**
......@@ -83,6 +86,25 @@ final class Config {
}
}
/**
* Migrate custom settings from composer.json if required.
*/
private function migrateFomrComposerJson(): void {
$filename = getcwd() . '/composer.json';
$jsonFile = new JsonFile($filename);
$content = $jsonFile->read();
if (isset($content['extra'][$this->component])) {
$this->merge([], $content['extra'][$this->component]);
$this->save();
unset($content['extra'][$this->component]);
try {
$jsonFile->write($content);
} catch (Exception $ex) {
// Let's ignore this, if composer.json is read-only there is a general problem.
}
}
}
/**
* @param array $defaultValues
* @param array $customValues
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment