Skip to content

Commit

Permalink
+ Absolute path mode for simple DeployLive job
Browse files Browse the repository at this point in the history
  • Loading branch information
iskrisis committed Apr 13, 2022
1 parent 8502cad commit d49be98
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/DeployLive.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@ class DeployLive extends \Bnomei\JanitorJob
*/
public function job(): array
{
if(!$siteFolder = option('floriankarsten.simplestaging.destination')) {
if(!$destination = option('floriankarsten.simplestaging.destination')) {
return [
'status' => 500,
'label' => 'floriankarsten.simplestaging.destination is not set',
'error' => 'floriankarsten.simplestaging.destination is not set',
];
}
$absoluteMode = option('floriankarsten.simplestaging.absolute');

// base is folder that holds whole website that should be duplicated. By default its parent of index/public folder
if(option('floriankarsten.simplestaging.base')) {
$base = option('floriankarsten.simplestaging.base');
} else {
$base = dirname(kirby()->root('index'));
}

$tmpDestination = dirname($base) . '/__staging_' . basename($base);
$finalDestination = dirname($base) . '/' . $siteFolder;
$toBeDeleted = dirname($base) . '/__tobedeleted_' . $siteFolder;
if($absoluteMode) {
$tmpDestination = dirname($destination) . '/__staging_' . basename($base);
$finalDestination = dirname($destination) . '/' . basename($destination);
$toBeDeleted = dirname($destination) . '/__tobedeleted_' . basename($destination);
} else {
$tmpDestination = dirname($base) . '/__staging_' . basename($base);
$finalDestination = dirname($base) . '/' . $destination;
$toBeDeleted = dirname($base) . '/__tobedeleted_' . $destination;
}



Expand All @@ -44,6 +52,7 @@ public function job(): array
'error' => 'Temporary folder is not writable',
];
}

$exclude = [];
foreach(option('floriankarsten.simplestaging.basic.excludedir', []) as $folder) {
$exclude[] = $base . "/" . $folder;
Expand Down

0 comments on commit d49be98

Please sign in to comment.