Skip to content

Commit 429d649

Browse files
authored
Add option to set the update directory, default to current working directory. Remove composer automatic update.
1 parent 138a704 commit 429d649

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ To initialize the Updater class and start the update process, follow these steps
6262
string|null $mailer,
6363
array|null $sourceExclusions = ['path' => [], 'filename' => []],
6464
array|null $releaseExclusions = ['path' => [], 'filename' => []],
65-
bool $clear = true
65+
bool $clear = true,
66+
string $dir = ""
6667
);
6768
```
6869

@@ -74,7 +75,8 @@ To initialize the Updater class and start the update process, follow these steps
7475
> `$mailer` (Optional) The email address that the email will be sent from.<br>
7576
> `$sourceExclusions` (Optional) An array of directories or files in the source to be exclude from the update.<br>
7677
> `$releaseExclusions` (Optional) An array of directories or files in the release to exclude from the update.<br>
77-
> `$clear` (Optional) Clear the downloaded file after the update has completed if set to true.
78+
> `$clear` (Optional) Clear the downloaded file after the update has completed if set to true.<br>
79+
> `$dir` (Optional) Set the directory of the update. Default to current working dir.
7880
7981
> The exclusions array keys:
8082

src/Updater.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class Updater
4343
* 'filename' => an array of release excluded filenames
4444
* @return void
4545
*/
46-
public function __construct(string $username, string $repository, string $token, string $version, string|null $admin = '', string|null $mailer = '', array|null $sourceExclusions = ['path' => [], 'filename' => []], array|null $releaseExclusions = ['path' => [], 'filename' => []], bool $clear = true)
46+
public function __construct(string $username, string $repository, string $token, string $version, string|null $admin = '', string|null $mailer = '', array|null $sourceExclusions = ['path' => [], 'filename' => []], array|null $releaseExclusions = ['path' => [], 'filename' => []], bool $clear = true, $dir = "")
4747
{
4848
$this->status = $this::STARTED;
4949

@@ -86,7 +86,11 @@ public function __construct(string $username, string $repository, string $token,
8686
$this->exclude = ['source' => $sourceExclusions, 'release' => $releaseExclusions];
8787
$this->clear = $clear;
8888

89-
$this->dir = getcwd();
89+
if($dir != ""){
90+
$this->dir = $dir;
91+
} else {
92+
$this->dir = getcwd();
93+
}
9094

9195
$update = $this->Install();
9296

@@ -96,17 +100,6 @@ public function __construct(string $username, string $repository, string $token,
96100
}
97101
}
98102
$this->Log();
99-
if ($update == $this::UPDATED) {
100-
if (class_exists('Composer\Autoload\ClassLoader')) {
101-
if (is_dir(exec('which composer'))) {
102-
exec('composer install -d ' . getcwd());
103-
} elseif (file_exists(getcwd() . '/composer.phar')) {
104-
exec('php composer.phar install -d ' . getcwd());
105-
} elseif (file_exists(($composer_path = exec('find / -name "composer.phar" 2>/dev/null')))) {
106-
exec('php ' . $composer_path . ' install -d ' . getcwd());
107-
}
108-
}
109-
}
110103
$this->status = $update;
111104
}
112105

0 commit comments

Comments
 (0)