From b53db71db6e03b2c2619164df9cd40db4ebf78a6 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Tue, 27 Jan 2026 21:22:57 +0000 Subject: [PATCH] Build: copyBlockAssets: Use cpSync for proper recursive copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue first described in https://github.com/WordPress/gutenberg/pull/74805#issuecomment-3800272544 Replace manual file iteration via `fs.cpSync` — which didn't support unexpected nested directories in block types' source dirs — with `fs.cpSync`. --- tools/gutenberg/copy-gutenberg-build.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/gutenberg/copy-gutenberg-build.js b/tools/gutenberg/copy-gutenberg-build.js index aa30d92264bf9..f123d3776617a 100644 --- a/tools/gutenberg/copy-gutenberg-build.js +++ b/tools/gutenberg/copy-gutenberg-build.js @@ -223,16 +223,15 @@ function copyBlockAssets( config ) { // 1. Copy scripts/JSON (everything except PHP) const blockScriptsSrc = path.join( scriptsSrc, blockName ); if ( fs.existsSync( blockScriptsSrc ) ) { - const files = fs.readdirSync( blockScriptsSrc ); - for ( const file of files ) { - if ( file.endsWith( '.php' ) ) { - continue; // Skip PHP, copied from packages + fs.cpSync( + blockScriptsSrc, + blockDest, + { + recursive: true, + // Skip PHP, copied from packages + filter: f => ! f.endsWith( '.php' ), } - fs.copyFileSync( - path.join( blockScriptsSrc, file ), - path.join( blockDest, file ) - ); - } + ); } // 2. Copy styles (if they exist in per-block directory)