Skip to content

Commit

Permalink
Restruct the browserlist:update to the latest dist tag on trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed May 10, 2022
1 parent c5b4370 commit 848ba38
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions Gruntfile.js
Expand Up @@ -3,6 +3,7 @@
/* globals Set */
var webpackConfig = require( './webpack.config' );
var installChanged = require( 'install-changed' );
const { spawnSync: spawn } = require( "child_process" );

module.exports = function(grunt) {
var path = require('path'),
Expand Down Expand Up @@ -1219,22 +1220,24 @@ module.exports = function(grunt) {
] );

grunt.registerTask( 'sync-gutenberg-packages', function() {
if ( grunt.option( 'update-browserlist' ) ) {
/*
* Updating the browserlist database is opt-in and up to the release lead.
*
* Browserlist database should be updated:
* - In each release cycle up until RC1
* - If Webpack throws a warning about an outdated database
*
* It should not be updated:
* - After the RC1
* - When backporting fixes to older WordPress releases.
*
* For more context, see:
* https://github.com/WordPress/wordpress-develop/pull/2621#discussion_r859840515
* https://core.trac.wordpress.org/ticket/55559
*/
/*
* Browserlist database should be updated when the packages are
* being updated to their latest version in the trunk branch.
*
* It should not happen during the patch releases. Otherwise,
* we'd be changing the supported browsers of a WP release on patch release.
*
* For more context, see:
*
* https://github.com/WordPress/gutenberg/issues/33344
* https://core.trac.wordpress.org/ticket/55559
*/
const distTag = grunt.option('dist-tag') || 'latest';
const currentBranch = spawn( 'git', [ 'branch', '--show-current' ], {
cwd: __dirname,
} ).stdout.toString().trim();

if ( distTag === 'latest' && currentBranch === 'trunk' ) {
grunt.task.run( 'browserslist:update' );
}

Expand Down

0 comments on commit 848ba38

Please sign in to comment.