Skip to content

Commit 2b1bf18

Browse files
authored
Merge pull request #1823 from WordPress/support/pre-release-version-syntax
Add support for pre-release version syntax to all relevant tools
2 parents 0615c18 + 9b6dccb commit 2b1bf18

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

bin/plugin/commands/readme.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function updateReadmeChangelog( readmeFile, changelog ) {
5454
const fileContent = fs.readFileSync( readmeFile, 'utf-8' );
5555

5656
const stableTagVersionMatches = fileContent.match(
57-
/^Stable tag:\s*(\d+\.\d+\.\d+)$/m
57+
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
5858
);
5959
if ( ! stableTagVersionMatches ) {
6060
throw new Error( `Unable to locate stable tag in ${ readmeFile }` );
@@ -112,7 +112,7 @@ function getStableTag( readmeFilePath ) {
112112
const readmeContents = fs.readFileSync( readmeFilePath, 'utf-8' );
113113

114114
const stableTagVersionMatches = readmeContents.match(
115-
/^Stable tag:\s*(\d+\.\d+\.\d+)$/m
115+
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
116116
);
117117
if ( ! stableTagVersionMatches ) {
118118
throw new Error( `Unable to locate stable tag in ${ readmeFilePath }` );

bin/plugin/commands/since.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ exports.handler = async ( opt ) => {
6161
const readmeFile = path.resolve( pluginDirectory, 'readme.txt' );
6262
const readmeContent = fs.readFileSync( readmeFile, 'utf-8' );
6363
const readmeContentMatches = readmeContent.match(
64-
/^Stable tag:\s+(\d+\.\d+\.\d+)$/m
64+
/^Stable tag:\s+(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
6565
);
6666
if ( ! readmeContentMatches ) {
6767
throw new Error(

bin/plugin/commands/versions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ async function checkPluginDirectory( pluginDirectory ) {
3838
const readmeContents = fs.readFileSync( readmeFilePath, 'utf-8' );
3939

4040
const stableTagVersionMatches = readmeContents.match(
41-
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-\w+)?)$/m
41+
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
4242
);
4343
if ( ! stableTagVersionMatches ) {
4444
throw new Error( `Unable to locate stable tag in ${ readmeFilePath }` );
4545
}
4646
const stableTagVersion = stableTagVersionMatches[ 1 ];
4747

4848
const latestChangelogMatches = readmeContents.match(
49-
/^== Changelog ==\n+= (\d+\.\d+\.\d+(?:-\w+)?) =$/m
49+
/^== Changelog ==\n+= (\d+\.\d+\.\d+(?:-[\w\.]+)?) =$/m
5050
);
5151
if ( ! latestChangelogMatches ) {
5252
throw new Error(
53-
'Unable to latest version entry in readme changelog.'
53+
'Unable to locate latest version entry in readme changelog.'
5454
);
5555
}
5656
const latestChangelogVersion = latestChangelogMatches[ 1 ];
@@ -71,7 +71,7 @@ async function checkPluginDirectory( pluginDirectory ) {
7171
}
7272

7373
const headerVersionMatches = phpBootstrapFileContents.match(
74-
/^ \* Version:\s+(\d+\.\d+\.\d+(?:-\w+)?)$/m
74+
/^ \* Version:\s+(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
7575
);
7676
if ( ! headerVersionMatches ) {
7777
throw new Error(
@@ -81,7 +81,7 @@ async function checkPluginDirectory( pluginDirectory ) {
8181
const headerVersion = headerVersionMatches[ 1 ];
8282

8383
const phpLiteralVersionMatches = phpBootstrapFileContents.match(
84-
/'(\d+\.\d+\.\d+(?:-\w+)?)'/
84+
/'(\d+\.\d+\.\d+(?:-[\w\.]+)?)'/
8585
);
8686
if ( ! phpLiteralVersionMatches ) {
8787
throw new Error( 'Unable to locate the PHP literal version.' );

tools/webpack/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const getPluginVersion = ( pluginPath ) => {
3737
const readmePath = path.resolve( pluginPath, 'readme.txt' );
3838

3939
const fileContent = fs.readFileSync( readmePath, 'utf-8' );
40-
const versionRegex = /(?:Stable tag|v)\s*:\s*(\d+\.\d+\.\d+)/i;
40+
const versionRegex = /(?:Stable tag|v)\s*:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)/i;
4141
const match = versionRegex.exec( fileContent );
4242

4343
if ( match ) {

0 commit comments

Comments
 (0)