MCPcopy Index your code
hub / github.com/nodejs/node / moveCollaboratorToEmeritus

Function moveCollaboratorToEmeritus

tools/find-inactive-collaborators.mjs:98–175  ·  view source on GitHub ↗
(peopleToMove)

Source from the content-addressed store, hash-verified

96}
97
98async function moveCollaboratorToEmeritus(peopleToMove) {
99 const readmeText = readline.createInterface({
100 input: fs.createReadStream(new URL('../README.md', import.meta.url)),
101 crlfDelay: Infinity,
102 });
103 let fileContents = '';
104 let inCollaboratorsSection = false;
105 let inCollaboratorEmeritusSection = false;
106 let collaboratorFirstLine = '';
107 const textToMove = [];
108 for await (const line of readmeText) {
109 // If we've been processing collaborator emeriti and we reach the end of
110 // the list, print out the remaining entries to be moved because they come
111 // alphabetically after the last item.
112 if (inCollaboratorEmeritusSection && line === '' &&
113 fileContents.endsWith('>\n')) {
114 while (textToMove.length) {
115 fileContents += textToMove.pop();
116 }
117 }
118
119 // If we've found the collaborator heading already, stop processing at the
120 // next heading.
121 if (line.startsWith('#')) {
122 inCollaboratorsSection = false;
123 inCollaboratorEmeritusSection = false;
124 }
125
126 const isCollaborator = inCollaboratorsSection && line.length;
127 const isCollaboratorEmeritus = inCollaboratorEmeritusSection && line.length;
128
129 if (line === '### Collaborators') {
130 inCollaboratorsSection = true;
131 }
132 if (line === '### Collaborator emeriti') {
133 inCollaboratorEmeritusSection = true;
134 }
135
136 if (isCollaborator) {
137 if (line.startsWith('* ')) {
138 collaboratorFirstLine = line;
139 } else if (line.startsWith(' **')) {
140 const [, name, email] = /^ {2}\*\*([^*]+)\*\* <<(.+)>>/.exec(line);
141 if (peopleToMove.some((entry) => {
142 return entry.name === name && entry.email === email;
143 })) {
144 textToMove.push(`${collaboratorFirstLine}\n${line}\n`);
145 } else {
146 fileContents += `${collaboratorFirstLine}\n${line}\n`;
147 }
148 } else {
149 fileContents += `${line}\n`;
150 }
151 }
152
153 if (isCollaboratorEmeritus) {
154 if (line.startsWith('* ')) {
155 collaboratorFirstLine = line;

Callers 1

Calls 6

popMethod · 0.80
someMethod · 0.80
createReadStreamMethod · 0.45
execMethod · 0.45
pushMethod · 0.45
shiftMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…