Skip to content

Commit 4c96d3b

Browse files
committed
Refactor post-install-cmd
1 parent 2275abf commit 4c96d3b

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
},
2525
"scripts" : {
2626
"post-install-cmd": [
27-
"Kenjis\\CodeIgniter\\Installer::postInstall",
28-
"composer update",
29-
"Kenjis\\CodeIgniter\\Installer::showMessage"
27+
"Kenjis\\CodeIgniter\\Installer::postInstall"
3028
]
3129
},
3230
"extra": {

src/Installer.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class Installer
2323
*/
2424
public static function postInstall(Event $event = null)
2525
{
26+
// Copy CodeIgniter files
2627
self::recursiveCopy('vendor/codeigniter/framework/application', 'application');
27-
2828
mkdir(static::DOCROOT, 0755);
2929
copy('vendor/codeigniter/framework/index.php', static::DOCROOT . '/index.php');
3030
copy('dot.htaccess', static::DOCROOT . '/.htaccess');
@@ -52,23 +52,39 @@ public static function postInstall(Event $event = null)
5252
'$config[\'composer_autoload\'] = realpath(APPPATH . \'../vendor/autoload.php\');',
5353
$contents
5454
);
55+
5556
// Set 'index_page' blank
5657
$contents = str_replace(
5758
'$config[\'index_page\'] = \'index.php\';',
5859
'$config[\'index_page\'] = \'\';',
5960
$contents
6061
);
6162
file_put_contents($file, $contents);
62-
63+
64+
// Update composer.json
6365
copy('composer.json.dist', 'composer.json');
66+
67+
// Run composer update
68+
self::composerUpdate();
69+
70+
// Show message
71+
self::showMessage($event);
72+
73+
// Delete unneeded files
74+
self::deleteSelf();
75+
}
76+
77+
private static function composerUpdate()
78+
{
79+
passthru('composer update');
6480
}
6581

6682
/**
6783
* Composer post install script
6884
*
6985
* @param Event $event
7086
*/
71-
public static function showMessage(Event $event = null)
87+
private static function showMessage(Event $event = null)
7288
{
7389
$io = $event->getIO();
7490
$io->write('==================================================');
@@ -83,8 +99,6 @@ public static function showMessage(Event $event = null)
8399
$io->write('<info>Above command will show help message.</info>');
84100
$io->write('See <https://github.com/kenjis/codeigniter-composer-installer> for details');
85101
$io->write('==================================================');
86-
87-
self::deleteSelf();
88102
}
89103

90104
private static function deleteSelf()

0 commit comments

Comments
 (0)