2
0
Fork 0
mirror of https://github.com/elementor/hello-theme.git synced 2026-03-03 12:56:14 +08:00
hello-theme/.github/scripts/get-changelog-from-readme-txt.js
ronkelementor e5944194d2
New: Copy GitHub actions from next release for releases (#167)
* New: Add GitHub actions for releases

* delete build + lint workflows
2021-06-21 13:16:26 +03:00

28 lines
749 B
JavaScript

'use strict';
const marked = require("marked");
const fs = require('fs');
const { VERSION } = process.env;
if (!VERSION) {
console.error('missing VERSION env var');
process.exit(1);
return;
}
(async () => {
try {
const changelogText = fs.readFileSync('readme.txt', 'utf-8');
const data = marked.lexer(changelogText);
const headerIndex = data.findIndex((section) => section.type === 'paragraph' && section.text.startsWith(`= ${VERSION}`));
if (headerIndex === -1) {
console.error(`Failed to find version: ${VERSION} in readme.txt file`);
process.exit(1);
return;
}
const versionLog = data[headerIndex + 1].raw;
fs.writeFileSync('temp-changelog-from-readme.txt', versionLog);
} catch (err) {
process.exit(1);
}
})();