chore: converting things to js

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-09-10 16:25:31 +02:00
parent 043972f325
commit 28e2ca1ed8
4 changed files with 9 additions and 12 deletions
+21
View File
@@ -0,0 +1,21 @@
const fs = require('fs');
const path = require('path');
const docsDir = path.resolve(__dirname, '../docs');
exports.releases = fs
.readdirSync(path.resolve(docsDir, 'releases'))
.filter(doc => doc.match(/^v\d+\.\d+\.\d+\.md$/))
.map(doc => doc.replace(/\.md$/, ''))
.sort((a, b) => {
// Semver sort
const aVal = a
.slice(1)
.split('.')
.reduce((acc, val) => acc * 1000 + parseInt(val), 0);
const bVal = b
.slice(1)
.split('.')
.reduce((acc, val) => acc * 1000 + parseInt(val), 0);
return bVal - aVal;
});