Skip to content

Commit

Permalink
Merge pull request #13225 from craftcms/move-set-vendor-path
Browse files Browse the repository at this point in the history
Share setVendorPath with cli
  • Loading branch information
brandonkelly authored May 26, 2023
2 parents 57556c7 + 3ba046a commit fa130b5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 26 additions & 0 deletions src/base/ApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,32 @@ trait ApplicationTrait
*/
private bool $_waitingToSaveInfo = false;

/**
* @inheritdoc
*/
public function setVendorPath($path): void
{
parent::setVendorPath($path);

// Override the @bower and @npm aliases if using asset-packagist.org
// todo: remove this whenever Yii is updated with support for asset-packagist.org
$altBowerPath = $this->getVendorPath() . DIRECTORY_SEPARATOR . 'bower-asset';
$altNpmPath = $this->getVendorPath() . DIRECTORY_SEPARATOR . 'npm-asset';
if (is_dir($altBowerPath)) {
Craft::setAlias('@bower', $altBowerPath);
}
if (is_dir($altNpmPath)) {
Craft::setAlias('@npm', $altNpmPath);
}

// Override where Yii should find its asset deps
$assetsPath = Craft::getAlias('@craft') . '/web/assets';
Craft::setAlias('@bower/jquery/dist', $assetsPath . '/jquery/dist');
Craft::setAlias('@bower/inputmask/dist', $assetsPath . '/inputmask/dist');
Craft::setAlias('@bower/punycode', $assetsPath . '/punycode/dist');
Craft::setAlias('@bower/yii2-pjax', $assetsPath . '/yii2pjax/dist');
}

/**
* Sets the target application language.
*
Expand Down
26 changes: 0 additions & 26 deletions src/web/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,32 +312,6 @@ public function runAction($route, $params = []): ?BaseResponse
return $response;
}

/**
* @inheritdoc
*/
public function setVendorPath($path): void
{
parent::setVendorPath($path);

// Override the @bower and @npm aliases if using asset-packagist.org
// todo: remove this whenever Yii is updated with support for asset-packagist.org
$altBowerPath = $this->getVendorPath() . DIRECTORY_SEPARATOR . 'bower-asset';
$altNpmPath = $this->getVendorPath() . DIRECTORY_SEPARATOR . 'npm-asset';
if (is_dir($altBowerPath)) {
Craft::setAlias('@bower', $altBowerPath);
}
if (is_dir($altNpmPath)) {
Craft::setAlias('@npm', $altNpmPath);
}

// Override where Yii should find its asset deps
$assetsPath = Craft::getAlias('@craft') . '/web/assets';
Craft::setAlias('@bower/jquery/dist', $assetsPath . '/jquery/dist');
Craft::setAlias('@bower/inputmask/dist', $assetsPath . '/inputmask/dist');
Craft::setAlias('@bower/punycode', $assetsPath . '/punycode/dist');
Craft::setAlias('@bower/yii2-pjax', $assetsPath . '/yii2pjax/dist');
}

/**
* @inheritdoc
*/
Expand Down

0 comments on commit fa130b5

Please sign in to comment.