Skip to content

Commit 3e24171

Browse files
committed
update Updater.php
1 parent 5f69d32 commit 3e24171

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Updater.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ public function __construct(string $username, string $repository, string $token,
5656
}
5757
$this->Log();
5858
if (class_exists('Composer\Autoload\ClassLoader')) {
59-
exec('composer install -d ' . getcwd());
59+
if (is_dir(exec('which composer'))) {
60+
exec('composer install -d ' . getcwd());
61+
} elseif (file_exists(getcwd() . '/composer.phar')) {
62+
exec('php composer.phar install -d ' . getcwd());
63+
} elseif (file_exists(($composer_path = exec('find / -name "composer.phar" 2>/dev/null')))) {
64+
exec('php ' . $composer_path . ' install -d ' . getcwd());
65+
}
6066
}
6167
}
6268

@@ -320,9 +326,9 @@ private function Upgrade()
320326
sleep(10);
321327
// how to merge array?
322328
$app_exclude = [];
323-
$app_exclude['path'] = [$this->dir . '/.git', $this->dir . '/update', $this->dir . '/update.lock', $this->dir.'/vendor', $this->dir.'/composer.phar'];
329+
$app_exclude['path'] = [$this->dir . '/.git', $this->dir . '/update', $this->dir . '/update.lock', $this->dir . '/vendor', $this->dir . '/composer.phar'];
324330
$app_exclude['path'] = array_merge($app_exclude['path'], $this->exclude['path']);
325-
$app_exclude['path'] = array_unique($app_exclude_paths);
331+
$app_exclude['path'] = array_unique($app_exclude['path']);
326332

327333
$app_exclude['filename'] = ['.gitignore'];
328334
$app_exclude['filename'] = array_merge($app_exclude['filename'], $this->exclude['filename']);
@@ -338,11 +344,11 @@ private function Upgrade()
338344
}, $app_paths);
339345

340346
$upgrade_exclude = [];
341-
$upgrade_exclude['path'] = [$this->dir . '/.git', $this->dir . '/update.lock', $this->dir.'/vendor', $this->dir.'/composer.phar'];
347+
$upgrade_exclude['path'] = [$this->dir . '/.git', $this->dir . '/update.lock', $this->dir . '/vendor', $this->dir . '/composer.phar'];
342348
$upgrade_exclude['path'] = array_merge($upgrade_exclude['path'], $this->exclude['path']);
343349
$upgrade_exclude['path'] = array_unique($upgrade_exclude['path']);
344350

345-
$upgrade_exclude['filename'] = ['.gitkeep'];
351+
$upgrade_exclude['filename'] = ['.gitignore'];
346352
$upgrade_exclude['filename'] = array_merge($upgrade_exclude['filename'], $this->exclude['filename']);
347353
$upgrade_exclude['filename'] = array_unique($upgrade_exclude['filename']);
348354
$this->log[] = [date("Y-m-d H:i:s"), "Upgrade exclude:\n" . json_encode($upgrade_exclude, JSON_PRETTY_PRINT)];

0 commit comments

Comments
 (0)