From 9aec9f5ba37b64d03204c004e7c5fc298837cc60 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 17 Dec 2024 17:38:50 +1000 Subject: [PATCH] Pull templates from `templates` too. --- actions/ui-check/tests/unit/index.block.test.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/actions/ui-check/tests/unit/index.block.test.js b/actions/ui-check/tests/unit/index.block.test.js index c0d5faf..ed02107 100644 --- a/actions/ui-check/tests/unit/index.block.test.js +++ b/actions/ui-check/tests/unit/index.block.test.js @@ -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', @@ -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` ), ]; };