Add ScriptHandler
This commit is contained in:
parent
f301190c15
commit
9cee380674
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
28
scripts/composer/ScriptHandler.php
Normal file
28
scripts/composer/ScriptHandler.php
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue