Skip to content

Commit dc62ecb

Browse files
committed
Build: Fix copyBlockAssets's handling of folders.
When copying block-type assets from Gutenberg to Core, use Node's `fs.cp` instead of `fs.copy`. The former has much better semantics for wholesale copies. Fixes build failures arising from the introduction of subdirectories in the source directories of certain core block types. Reviewed by youknowriad. Fixes #64559. git-svn-id: https://develop.svn.wordpress.org/trunk@61567 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d200a15 commit dc62ecb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

tools/gutenberg/copy-gutenberg-build.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,15 @@ function copyBlockAssets( config ) {
223223
// 1. Copy scripts/JSON (everything except PHP)
224224
const blockScriptsSrc = path.join( scriptsSrc, blockName );
225225
if ( fs.existsSync( blockScriptsSrc ) ) {
226-
const files = fs.readdirSync( blockScriptsSrc );
227-
for ( const file of files ) {
228-
if ( file.endsWith( '.php' ) ) {
229-
continue; // Skip PHP, copied from packages
226+
fs.cpSync(
227+
blockScriptsSrc,
228+
blockDest,
229+
{
230+
recursive: true,
231+
// Skip PHP, copied from packages
232+
filter: f => ! f.endsWith( '.php' ),
230233
}
231-
fs.copyFileSync(
232-
path.join( blockScriptsSrc, file ),
233-
path.join( blockDest, file )
234-
);
235-
}
234+
);
236235
}
237236

238237
// 2. Copy styles (if they exist in per-block directory)

0 commit comments

Comments
 (0)