Skip to content

Allow underscore in extended static files in theme #32620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Magento\Framework\App\Utility;

use Magento\Framework\App\Utility\Files;
use Magento\Framework\Component\ComponentRegistrar;

class FilesTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -159,4 +158,24 @@ public function testReadLists()
}
$this->assertSame($expected, $actual);
}

/**
* Tests if underscores are allowed in extended static files in theme.
*
* @magentoComponentsDir Magento/Framework/App/Utility/_files/design
* @magentoAppIsolation enabled
* @magentoDbIsolation enabled
*/
public function testAllowUnderscoreInExtendedFiles()
{
$this->assertNotEmpty(
array_filter(
$this->model->getStaticPreProcessingFiles('*.less'),
function ($resource) {
return $resource[3] === 'Module_Third_Party'
&& $resource[4] === 'css/source/_module.less';
}
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
.a-random-css-rule {
background: red;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/FrameworkUtilityTest/default', __DIR__);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>Test Default</title>
</theme>
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/App/Utility/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ private function accumulateThemeStaticFiles($area, $locale, $filePattern, &$resu
];
$this->_accumulateFilesByPatterns($paths, $filePattern, $files);
$regex = '#^' . $themePath .
'/((?P<module>[a-z\d]+_[a-z\d]+)/)?web/(i18n/(?P<locale>[a-z_]+)/)?(?P<path>.+)$#i';
'/((?P<module>[a-z\d]+_[a-z_\d]+)/)?web/(i18n/(?P<locale>[a-z_]+)/)?(?P<path>.+)$#i';
foreach ($files as $file) {
if (preg_match($regex, $file, $matches)) {
$result[] = [
Expand Down