Skip to content

Commit

Permalink
Simplify core source parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
noahtallen committed Aug 15, 2022
1 parent 408de61 commit 5c7914e
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions packages/env/lib/config/parse-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ module.exports = async function parseConfig( config, options ) {
port: config.port,
phpVersion: config.phpVersion,
coreSource: includeTestsPath(
parseSourceString(
await getCoreSourceString( config.core ),
options
),
await parseCoreSource( config.core, options ),
options
),
pluginSources: config.plugins.map( ( sourceString ) =>
Expand All @@ -62,17 +59,19 @@ module.exports = async function parseConfig( config, options ) {
};
};

async function getCoreSourceString( coreSource ) {
if ( coreSource ) {
return coreSource;
}
const wpVersion = await getLatestWordPressVersion();
if ( ! wpVersion ) {
throw new ValidationError(
'Could not find the latest WordPress version. There may be a network issue.'
);
async function parseCoreSource( coreSource, options ) {
// An empty source means we should use the latest version of WordPress.
if ( ! coreSource ) {
const wpVersion = await getLatestWordPressVersion();
if ( ! wpVersion ) {
throw new ValidationError(
'Could not find the latest WordPress version. There may be a network issue.'
);
}

coreSource = `WordPress/WordPress#${ wpVersion }`;
}
return `WordPress/WordPress#${ wpVersion }`;
return parseSourceString( coreSource, options );
}

/**
Expand Down

0 comments on commit 5c7914e

Please sign in to comment.