mirror of
https://github.com/danpros/htmly.git
synced 2026-04-21 04:56:23 +05:30
[TASK] add upgrade specific stuff (e.g.: delete vendor/)
This commit is contained in:
parent
e8b517b7bd
commit
3ded899feb
4 changed files with 49 additions and 0 deletions
4
system/upgrade/index.php
Normal file
4
system/upgrade/index.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
require 'system/vendor/autoload.php';
|
||||
require 'system/htmly.php';
|
||||
40
system/upgrade/run.php
Normal file
40
system/upgrade/run.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
$updater = new Kanti\HubUpdater("danpros/htmly");
|
||||
$info = $updater->getCurrentInfo();
|
||||
$versionNumber = substr($info['tag_name'],1);
|
||||
|
||||
function isGraterThan($string){
|
||||
global $versionNumber;
|
||||
return (version_compare($versionNumber,$string) > 0);
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
|
||||
function rrmdir($dir) {
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
//run upgrade specific stuff
|
||||
if(isGraterThan("2.3")) {// 2.4, 2.5, ...
|
||||
echo "yes";
|
||||
if(file_exists("vendor/")){
|
||||
rrmdir("vendor/");
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo "no";
|
||||
}
|
||||
|
||||
if(isGraterThan("2.3")) {
|
||||
file_put_contents("index.php",file_get_contents("system/upgrade/index.php"));
|
||||
rrmdir("system/upgrade/");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue