feat(createPackage): sort label files (#8892)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2022-12-01 10:02:44 +00:00
committed by GitHub
parent 5e4331062b
commit f13ff5c6d3
3 changed files with 12 additions and 6 deletions

View File

@@ -58,12 +58,19 @@ export async function createPackage(packageName: string, packageDescription?: st
const labelsYAML = parseYAML(await readFile('labels.yml', 'utf8')) as LabelerData[];
labelsYAML.push({ name: `packages:${packageName}`, color: 'fbca04' });
labelsYAML.sort((a, b) => a.name.localeCompare(b.name));
await writeFile('labels.yml', stringifyYAML(labelsYAML));
const labelerYAML = parseYAML(await readFile('labeler.yml', 'utf8')) as Record<string, string[]>;
labelerYAML[`packages:${packageName}`] = [`packages/${packageName}/*`, `packages/${packageName}/**/*`];
await writeFile('labeler.yml', stringifyYAML(labelerYAML));
const sortedLabelerYAML: Record<string, string[]> = {};
for (const key of Object.keys(labelerYAML).sort((a, b) => a.localeCompare(b))) {
sortedLabelerYAML[key] = labelerYAML[key]!;
}
await writeFile('labeler.yml', stringifyYAML(sortedLabelerYAML));
// Move back to root
chdir('..');