2022-05-19 11:26:42 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
(async () => {
|
2022-06-22 13:25:44 +00:00
|
|
|
const {createReadStream} = require('fs');
|
|
|
|
const {join} = require('path');
|
|
|
|
const {createInterface} = require('readline');
|
2022-05-19 11:26:42 +00:00
|
|
|
|
|
|
|
const lines = [];
|
|
|
|
let isRecording = false;
|
|
|
|
|
|
|
|
for await (const line of createInterface({
|
|
|
|
input: createReadStream(join(__dirname, '../CHANGELOG.md'), {
|
|
|
|
encoding: 'utf-8',
|
|
|
|
}),
|
|
|
|
})) {
|
|
|
|
if (line.startsWith('## ')) {
|
|
|
|
if (!isRecording) {
|
|
|
|
isRecording = true;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isRecording) {
|
|
|
|
lines.push(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lines.length === 0) {
|
|
|
|
throw new Error('Latest changelog should be non-empty.');
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(lines.join('\n').trim());
|
|
|
|
})();
|