File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ const directoryPath = process.argv[2] || './gh-cli';
1212const headingLevel = process . argv [ 3 ] || '###' ;
1313const parentHeading = process . argv [ 4 ] || '## Scripts' ;
1414
15+ // Escape RegExp special characters
16+ function escapeRegExp ( string ) {
17+ return string . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
18+ }
1519const readmePath = path . join ( directoryPath , 'README.md' ) ;
1620
1721// Read README.md content
@@ -96,7 +100,7 @@ allScripts.forEach(file => {
96100const scriptsSection = readme . split ( `${ parentHeading } \n` ) [ 1 ] ;
97101
98102// Extract all ### headings from the scripts section
99- const regex = new RegExp ( `${ headingLevel } .*` , 'g' ) ;
103+ const regex = new RegExp ( `${ escapeRegExp ( headingLevel ) } .*` , 'g' ) ;
100104const headings = scriptsSection . match ( regex ) ;
101105
102106// Check that all scripts mentioned in the README.md actually exist in the repository
You can’t perform that action at this time.
0 commit comments