Add ScriptHandler

This commit is contained in:
Oliver Davies 2017-05-18 02:20:32 +01:00
parent f301190c15
commit 9cee380674
2 changed files with 42 additions and 1 deletions

View file

@ -10,7 +10,20 @@
}
],
"require": {
"sculpin/sculpin": "^2.1@dev",
"dflydev/embedded-composer": "^1.0@dev",
"sculpin/sculpin": "^2.1@dev"
},
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
]
},
"scripts": {
"post-install-cmd": [
"SculpinSkeleton\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"SculpinSkeleton\\composer\\ScriptHandler::createRequiredFiles"
]
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace SculpinSkeleton\composer;
use Composer\Script\Event;
use Symfony\Component\Filesystem\Filesystem;
class ScriptHandler
{
public static function createRequiredFiles(Event $event)
{
$fs = new Filesystem();
$sculpinRoot = getcwd();
$dirs = [
'app/config',
'source',
];
foreach ($dirs as $dir) {
if (!$fs->exists("$sculpinRoot/$dir")) {
$fs->mkdir("$sculpinRoot/$dir");
$fs->touch("$sculpinRoot/$dir/.gitkeep");
}
}
}
}