Skip to content

Commit c65d967

Browse files
authored
Pipeline tweaks (github#36065)
1 parent b80d696 commit c65d967

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

src/automated-pipelines/lib/update-markdown.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export const MARKDOWN_COMMENT =
1616

1717
// Main entrypoint into this module. This function adds, removes, and updates
1818
// versions frontmatter in all directories under the targetDirectory.
19-
export async function updateContentDirectory(
19+
export async function updateContentDirectory({
2020
targetDirectory,
2121
sourceContent,
2222
frontmatter,
23-
indexOrder
24-
) {
23+
indexOrder,
24+
}) {
2525
const sourceFiles = Object.keys(sourceContent)
2626
await createDirectory(targetDirectory)
2727
await removeMarkdownFiles(targetDirectory, sourceFiles, frontmatter.autogenerated)

src/automated-pipelines/tests/update-content-directory.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,19 @@ describe('automated content directory updates', () => {
7373

7474
// Rewrites the content directory in the operating system's
7575
// temp directory.
76-
await updateContentDirectory(
76+
await updateContentDirectory({
7777
targetDirectory,
78-
contentDataFullPath,
79-
{
78+
sourceContent: contentDataFullPath,
79+
frontmatter: {
8080
autogenerated: 'rest',
8181
},
82-
indexOrder
83-
)
82+
indexOrder,
83+
})
8484
})
8585

8686
afterAll(async () => {
8787
await rm(tempDirectory, { recursive: true, force: true })
88+
delete process.env.TEST_OS_ROOT_DIR
8889
})
8990

9091
test('expected files and directories are removed', async () => {

src/codeql-cli/scripts/sync.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ async function main() {
4343
cliMarkdownContents[targetFilename] = { data: sourceData, content: finalSourceContent }
4444
}
4545
// Begin updating Markdown files in the content directory
46-
await updateContentDirectory(targetDirectory, cliMarkdownContents, frontmatterDefaults)
46+
await updateContentDirectory({
47+
targetDirectory,
48+
sourceContent: cliMarkdownContents,
49+
frontmatter: frontmatterDefaults,
50+
})
4751
}
4852

4953
// Separates out steps that need to be done before the sync can begin

src/rest/scripts/utils/update-markdown.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ const { frontmatterDefaults, targetDirectory } = JSON.parse(
1717
export async function updateRestFiles() {
1818
const restVersions = await getDataFrontmatter(REST_DATA_DIR, REST_SCHEMA_FILENAME)
1919
const restMarkdownContent = await getMarkdownContent(restVersions)
20-
await updateContentDirectory(targetDirectory, restMarkdownContent, frontmatterDefaults)
20+
await updateContentDirectory({
21+
targetDirectory,
22+
sourceContent: restMarkdownContent,
23+
frontmatter: frontmatterDefaults,
24+
})
2125
}
2226

2327
// Reads data files from the directory provided and returns a
@@ -80,10 +84,12 @@ async function getMarkdownContent(versions) {
8084

8185
for (const category of Object.keys(versions)) {
8286
const subcategories = Object.keys(versions[category])
83-
// When there is only a single subcategory, the Markdown file
84-
// will be at the root of the content/rest directory. The
85-
// file path will be content/rest/<category>.md
86-
if (subcategories.length === 1) {
87+
// When there is only a single subcategory and the name
88+
// matches the category, this is an override due to a
89+
// subcategory not being defined. In this case,
90+
// the markdown file will be in the content/rest directory.
91+
// The file path will be content/rest/<category>.md
92+
if (subcategories.length === 1 && category === subcategories[0]) {
8793
// this will be a file in the root of the rest directory
8894
const filepath = path.join('content/rest', `${category}.md`)
8995
markdownUpdates[filepath] = {

0 commit comments

Comments
 (0)