Skip to content

Commit

Permalink
runPerformanceTests: Remap wpVersion to match ZIP path
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed May 31, 2021
1 parent 43516e7 commit 1217cff
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,24 @@ async function runPerformanceTests( branches, options ) {

log( '>> Starting the WordPress environment' );
if ( options.wpVersion ) {
// Patch the environment's .wp-env.json config to use the specified WP version:
// In order to match the topology of ZIP files at wp.org, remap .0
// patch versions to major versions:
//
// 5.7 -> 5.7 (unchanged)
// 5.7.0 -> 5.7 (changed)
// 5.7.2 -> 5.7.2 (unchanged)
const zipVersion = options.wpVersion.replace( /^(\d+\.\d+).0/, '$1' );
const zipUrl = `https:\\/\\/wordpress.org\\/wordpress-${ zipVersion }.zip`;

log( `Using WordPress version ${ zipVersion }` );

// Patch the environment's .wp-env.json config to use the specified WP
// version:
//
// {
// "core": "https://wordpress.org/wordpress-$VERSION",
// "core": "https://wordpress.org/wordpress-$VERSION.zip",
// ...
// }
//
// Only use the major version, i.e. 5.7.2 becomes 5.7.
const major = options.wpVersion.split( '.' ).slice( 0, 2 ).join( '.' );
const zipUrl = `https:\\/\\/wordpress.org\\/wordpress-${ major }.zip`;
log( `Using WordPress version ${ major }` );
await runShellScript(
`sed -I '' -e '/"core":/s/WordPress\\/WordPress/${ zipUrl }/' "${ environmentDirectory }/.wp-env.json"`
);
Expand Down

0 comments on commit 1217cff

Please sign in to comment.