@@ -10,21 +10,16 @@ if (!username) {
1010const readmePath = path . join ( process . cwd ( ) , 'README.md' ) ;
1111let readme = fs . readFileSync ( readmePath , 'utf8' ) ;
1212
13- // Where to add the Contributors section (after "Thanks for being part of Codextream")
1413const thankYouMarker = "## 🙌 Thanks for being part of Codextream!" ;
15-
16- // Contributor markdown line
14+ const contributorsHeader = "## Contributors" ;
1715const contributorLine = `- [@${ username } ](https://github.com/${ username } )` ;
1816
19- // Check if already present
17+ // Already present? Exit.
2018if ( readme . includes ( contributorLine ) ) {
2119 console . log ( 'Contributor already present. Skipping.' ) ;
2220 process . exit ( 0 ) ;
2321}
2422
25- const contributorsHeader = "## Contributors" ;
26- const insertSection = `\n${ contributorsHeader } \n${ contributorLine } \n` ;
27-
2823if ( readme . includes ( contributorsHeader ) ) {
2924 // Add to existing Contributors section (append if not present)
3025 const contribSectionRegex = / ( # # C o n t r i b u t o r s \s * \n ) ( (?: .| \n ) * ?) ( \n # # | \n # | \n $ ) / ;
@@ -43,10 +38,10 @@ if (readme.includes(contributorsHeader)) {
4338 const afterThankYouIndex = readme . indexOf ( '\n' , thankYouIndex ) ;
4439 const before = readme . slice ( 0 , afterThankYouIndex + 1 ) ;
4540 const after = readme . slice ( afterThankYouIndex + 1 ) ;
46- readme = before + insertSection + after ;
41+ readme = before + `\n ${ contributorsHeader } \n ${ contributorLine } \n` + after ;
4742} else {
4843 // Fallback: append at end
49- readme += insertSection ;
44+ readme += `\n ${ contributorsHeader } \n ${ contributorLine } \n` ;
5045}
5146
5247fs . writeFileSync ( readmePath , readme , 'utf8' ) ;
0 commit comments