Skip to content
Closed
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
20 changes: 19 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,25 @@ module.exports = function(grunt) {
args: [ 'tools/gutenberg/download.js' ],
opts: { stdio: 'inherit' }
}, function( error ) {
done( ! error );
if ( error ) {
done( false );
return;
}
/*
* Build block editor files into the src directory every time assets
* are downloaded. This prevents failures when running from src
* without running `build:dev` after those files were removed from
* version control in https://core.trac.wordpress.org/changeset/61438.
*
* See https://core.trac.wordpress.org/ticket/64393.
*/
grunt.util.spawn( {
grunt: true,
args: [ 'build:gutenberg', '--dev' ],
opts: { stdio: 'inherit' }
}, function( buildError ) {
done( ! buildError );
} );
} );
} );

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"typecheck:php": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan",
"gutenberg:copy": "node tools/gutenberg/copy.js",
"gutenberg:verify": "node tools/gutenberg/utils.js",
"gutenberg:download": "node tools/gutenberg/download.js",
"gutenberg:download": "node tools/gutenberg/download.js && grunt build:gutenberg --dev",
"vendor:copy": "node tools/vendors/copy-vendors.js",
"sync-gutenberg-packages": "grunt sync-gutenberg-packages",
"postsync-gutenberg-packages": "grunt wp-packages:sync-stable-blocks && grunt build --dev && grunt build"
Expand Down
16 changes: 11 additions & 5 deletions tools/gutenberg/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ function readGutenbergConfig() {
}

/**
* Trigger a fresh download of the Gutenberg artifact by spawning download.js.
* Exits the process if the download fails.
* Trigger a fresh download of the Gutenberg artifact by spawning download.js,
* then run `grunt build:gutenberg --dev` to copy the build to src/.
* Exits the process if either step fails.
*/
function downloadGutenberg() {
const result = spawnSync( 'node', [ path.join( __dirname, 'download.js' ) ], { stdio: 'inherit' } );
if ( result.status !== 0 ) {
process.exit( result.status ?? 1 );
const downloadResult = spawnSync( 'node', [ path.join( __dirname, 'download.js' ) ], { stdio: 'inherit' } );
if ( downloadResult.status !== 0 ) {
process.exit( downloadResult.status ?? 1 );
}

const buildResult = spawnSync( 'grunt', [ 'build:gutenberg', '--dev' ], { stdio: 'inherit', shell: true } );
if ( buildResult.status !== 0 ) {
process.exit( buildResult.status ?? 1 );
}
}

Expand Down
Loading