Skip to content

Commit

Permalink
Fix whitespace not matching in since command.
Browse files Browse the repository at this point in the history
This fixes an issue where the since command was failing to replace instances of `n.e.x.t` when more than once space occurred between the `@since` and the placeholder version number, e.g., for docblock alignment purposes.
  • Loading branch information
joemcgill committed Jul 13, 2023
1 parent 8e9250b commit 6287a8c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin/plugin/commands/since.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ exports.handler = async ( opt ) => {
ignore: [ __filename, '**/node_modules', '**/vendor' ],
} );

const regexp = new RegExp( '@since n.e.x.t', 'g' );
const regexp = new RegExp( '@since(\\s+)n.e.x.t', 'g' );

files.forEach( ( file ) => {
const content = fs.readFileSync( file, 'utf-8' );
if ( regexp.test( content ) ) {
fs.writeFileSync(
file,
content.replace( regexp, `@since ${ opt.release }` )
content.replace( regexp, `@since$1${ opt.release }` )
);
}
} );
Expand Down

0 comments on commit 6287a8c

Please sign in to comment.