Skip to content

Commit

Permalink
Add the ability to specify a custom directory for assets.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed May 27, 2024
1 parent d16db54 commit c1d3963
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
39 changes: 21 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Asset/AbstractAssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ public function run(): int
return 0;
}

$rootPackageDir = $this->config->get('root-package-dir');

if ($rootPackageDir !== null) {
\chdir($rootPackageDir);

Check failure on line 143 in src/Asset/AbstractAssetManager.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArgument: Argument 1 of chdir cannot be mixed, expecting string

Check failure on line 143 in src/Asset/AbstractAssetManager.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArgument: Argument 1 of chdir cannot be mixed, expecting string
}

$updatable = $this->isUpdatable();
$info = sprintf('<info>%s %s dependencies</info>', $updatable ? 'Updating' : 'Installing', $this->getName());
$this->io->write($info);
Expand Down
10 changes: 10 additions & 0 deletions src/Util/AssetUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public static function getPath(
if (self::isAsset($package, $configPackages)) {
$installPath = $installationManager->getInstallPath($package);

$composerJsonPath = $installPath . '/composer.json';

Check failure on line 58 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

PossiblyNullOperand: Cannot concatenate with a possibly null null|string

Check failure on line 58 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

PossiblyNullOperand: Cannot concatenate with a possibly null null|string

if (\file_exists($composerJsonPath)) {
$composerJson = \json_decode(\file_get_contents($composerJsonPath), true);

if (isset($composerJson['config']['foxy']['root-package-dir'])) {
$installPath .= '/' . $composerJson['config']['foxy']['root-package-dir'];

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

PossiblyNullOperand: Cannot concatenate with a possibly null null|string

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArrayAccess: Cannot access array value on mixed variable $composerJson

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArrayAccess: Cannot access array value on mixed variable $composerJson['config']

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArrayAccess: Cannot access array value on mixed variable $composerJson['config']['foxy']

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedOperand: Right operand cannot be mixed

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

PossiblyNullOperand: Cannot concatenate with a possibly null null|string

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArrayAccess: Cannot access array value on mixed variable $composerJson

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArrayAccess: Cannot access array value on mixed variable $composerJson['config']

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedArrayAccess: Cannot access array value on mixed variable $composerJson['config']['foxy']

Check failure on line 64 in src/Util/AssetUtil.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

MixedOperand: Right operand cannot be mixed
}
}

if ($installPath !== null) {
$filename = $installPath . '/' . $assetManager->getPackageName();
$path = \file_exists($filename) ? \str_replace('\\', '/', \realpath($filename)) : null;
Expand Down

0 comments on commit c1d3963

Please sign in to comment.