Skip to content

Commit 06bd5fc

Browse files
author
Maledong
authored
fixture of rendering error of "console" in Prism (#3699)
"Metal-Prism" needs a range of coding languages to be rendered with, however the script will generate some languages that don't match what it really needs. This is a fixture for it. For more, please see: #3695.
1 parent 745e311 commit 06bd5fc

3 files changed

Lines changed: 81 additions & 3 deletions

File tree

scripts/release-post.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ function fetchChangelog (version) {
103103
function fetchChangelogBody (version) {
104104
return fetchChangelog(version).then((section) => {
105105
const rxSectionBody = /(### Notable [\s\S]*)/
106+
107+
// Make sure that all the console has been replaced
108+
// by "```shell-session" for metalsmith-prism's check to pass
109+
const rxSectionConsole = /```console/igm
106110
const matches = rxSectionBody.exec(section)
107111
return matches
108-
? matches[1]
112+
? matches[1].trim().replace(rxSectionConsole, '```shell-session')
109113
: Promise.reject(new Error(`Could not find changelog body of ${version} release`))
110114
})
111115
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Node.js 15 ChangeLog
2+
3+
<!--lint disable prohibited-strings-->
4+
<!--lint disable maximum-line-length-->
5+
<!--lint disable no-literal-urls-->
6+
7+
<table>
8+
<tr>
9+
<th>Current</th>
10+
</tr>
11+
<tr>
12+
<td>
13+
<a href="#15.1.0">15.1.0</a><br/>
14+
<a href="#15.0.0">15.0.0</a><br/>
15+
</td>
16+
</tr>
17+
</table>
18+
19+
* Other Versions
20+
* [14.x](CHANGELOG_V14.md)
21+
* [13.x](CHANGELOG_V13.md)
22+
* [12.x](CHANGELOG_V12.md)
23+
* [11.x](CHANGELOG_V11.md)
24+
* [10.x](CHANGELOG_V10.md)
25+
* [9.x](CHANGELOG_V9.md)
26+
* [8.x](CHANGELOG_V8.md)
27+
* [7.x](CHANGELOG_V7.md)
28+
* [6.x](CHANGELOG_V6.md)
29+
* [5.x](CHANGELOG_V5.md)
30+
* [4.x](CHANGELOG_V4.md)
31+
* [0.12.x](CHANGELOG_V012.md)
32+
* [0.10.x](CHANGELOG_V010.md)
33+
* [io.js](CHANGELOG_IOJS.md)
34+
* [Archive](CHANGELOG_ARCHIVE.md)
35+
36+
<a id="15.1.0"></a>
37+
## Version 15.1.0 Test Part
38+
39+
### Notable Changes Test Part
40+
Here's the notable changes as an example for test
41+
42+
#### ```console to ```shell-session Test
43+
44+
```console
45+
$ npm run serve
46+
```
47+
```js
48+
console.log("Hello World");
49+
```
50+
51+
<a id="15.0.0"></a>
52+
## Version 15.0.0 Test Part
53+
54+
### Notable Changes Test
55+
Here's the notable changes test for v15.0.0.
56+
57+
#### ```console to ```shell-session Test
58+
```ConSole
59+
$ npm run start
60+
```

tests/scripts/release-post.test.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ test('fetchChangelog(<version>)', (t) => {
162162
test('fetchChangelogBody(<version>)', (t) => {
163163
const releasePost = require('../../scripts/release-post')
164164

165-
const changelogFixture = path.resolve(__dirname, 'CHANGELOG.fixture.md')
166-
167165
t.test('does not include `## header` in matched version section', (t) => {
166+
const changelogFixture = path.resolve(__dirname, 'CHANGELOG.fixture.md')
167+
168168
const github = nock('https://raw.githubusercontent.com')
169169
.get('/nodejs/node/master/doc/changelogs/CHANGELOG_V4.md')
170170
.replyWithFile(200, changelogFixture)
@@ -177,6 +177,20 @@ test('fetchChangelogBody(<version>)', (t) => {
177177
}, t.fail)
178178
})
179179

180+
t.test('does not include "```console', (t) => {
181+
const changelogFixture = path.resolve(__dirname, 'CHANGELOG.fixture.withconsole.md')
182+
183+
const githubWithConsole = nock('https://raw.githubusercontent.com')
184+
.get('/nodejs/node/master/doc/changelogs/CHANGELOG_V15.md')
185+
.replyWithFile(200, changelogFixture)
186+
187+
releasePost.fetchChangelogBody('15.1.0').then((body) => {
188+
t.false(body.includes('```console'))
189+
t.true(githubWithConsole.isDone(), 'githubusercontent.com was requested')
190+
t.end()
191+
}, t.fail)
192+
})
193+
180194
t.end()
181195
})
182196

0 commit comments

Comments
 (0)