Skip to content

Commit 7d5368c

Browse files
authoredJul 12, 2024··
ci: Updated bin/create-docs-pr to create an empty array if changelog.json is missing security (#2348)
1 parent b3f1ee3 commit 7d5368c

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed
 

‎bin/create-docs-pr.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ async function getFrontMatter(tagName, frontMatterFile) {
164164
}
165165

166166
return {
167-
security: JSON.stringify(frontmatter.changes.security),
168-
bugfixes: JSON.stringify(frontmatter.changes.bugfixes),
169-
features: JSON.stringify(frontmatter.changes.features)
167+
security: JSON.stringify(frontmatter.changes.security || []),
168+
bugfixes: JSON.stringify(frontmatter.changes.bugfixes || []),
169+
features: JSON.stringify(frontmatter.changes.features || [])
170170
}
171171
}
172172

‎bin/test/create-docs-pr.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ tap.test('Create Docs PR script', (testHarness) => {
7474
t.test('should throw an error if there is no frontmatter', async (t) => {
7575
mockFs.readFile.yields(null, JSON.stringify({ entries: [{ version: '1.2.3', changes: [] }] }))
7676

77+
// eslint-disable-next-line sonarjs/no-duplicate-string
7778
const func = () => script.getFrontMatter('v2.0.0', 'changelog.json')
7879
t.rejects(func, 'Unable to find 2.0.0 entry in changelog.json')
7980

@@ -106,6 +107,29 @@ tap.test('Create Docs PR script', (testHarness) => {
106107
})
107108
t.end()
108109
})
110+
111+
t.test('should return empty arrays if missing changes', async (t) => {
112+
mockFs.readFile.yields(
113+
null,
114+
JSON.stringify({
115+
entries: [
116+
{
117+
version: '2.0.0',
118+
changes: {}
119+
}
120+
]
121+
})
122+
)
123+
124+
const result = await script.getFrontMatter('v2.0.0', 'changelog.json')
125+
126+
t.same(result, {
127+
security: '[]',
128+
bugfixes: '[]',
129+
features: '[]'
130+
})
131+
t.end()
132+
})
109133
})
110134

111135
testHarness.test('formatReleaseNotes', (t) => {

‎changelog.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"version": "11.23.0",
1616
"changes": {
1717
"security": [],
18+
"bugfixes": [],
1819
"features": [
1920
"Added support for account level governance of AI Monitoring"
2021
]
@@ -514,4 +515,4 @@
514515
}
515516
}
516517
]
517-
}
518+
}

0 commit comments

Comments
 (0)
Please sign in to comment.