Skip to content

Commit

Permalink
Pull templates from templates too.
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 authored Dec 17, 2024
1 parent c29e893 commit 9aec9f5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions actions/ui-check/tests/unit/index.block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const THEME_ROOT_FOLDER = '../../test-theme';
const getFileContents = ( location ) => {
const arr = [];

if ( ! fs.existsSync( location ) ) {
return arr;
}

fs.readdirSync( location ).forEach( ( file ) => {
const contents = fs.readFileSync( `${ location }/${ file }`, {
encoding: 'utf8',
Expand All @@ -40,12 +44,11 @@ const getFileContents = ( location ) => {
* Collects the template parts from theme
*/
const getTemplates = () => {
const templateLocation = `${ THEME_ROOT_FOLDER }/block-templates`;
const templatePartLocation = `${ THEME_ROOT_FOLDER }/block-template-parts`;

return [
...getFileContents( templateLocation ),
...getFileContents( templatePartLocation ),
...getFileContents( `${ THEME_ROOT_FOLDER }/block-templates` ),
...getFileContents( `${ THEME_ROOT_FOLDER }/block-template-parts` ),
...getFileContents( `${ THEME_ROOT_FOLDER }/templates` ),
...getFileContents( `${ THEME_ROOT_FOLDER }/template-parts` ),
];
};

Expand Down

0 comments on commit 9aec9f5

Please sign in to comment.