Visitar URL original
Merge pull request #722 from processing/fix_latest_txt · processing/processing-website@42aca9a · GitHub
Skip to content

Commit 42aca9a

Browse files
authored
Merge pull request #722 from processing/fix_latest_txt
Get the highest build number and use that value for latest.txt
2 parents 86a68e8 + c2dde33 commit 42aca9a

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎gatsby-node.js‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,21 @@ async function createDownloadAndReleases(actions, graphql) {
407407
This only happens on build, not on dev.
408408
**/
409409
exports.onPostBuild = () => {
410-
const releases = require('./content/download/selected.json');
411-
const latest = releases.selectedReleases[0];
412-
const [name, number, version] = latest.split('-');
410+
const { selectedReleases } = require('./content/download/selected.json');
411+
// The PDE expects the highest build number (e.g. 1435), so pick it
412+
// regardless of array order and skip tags without one (e.g. processing-1.5.1)
413+
const build = selectedReleases
414+
.map((tag) => tag.match(/^processing-(\d+)-/))
415+
.filter(Boolean)
416+
.map((match) => Number(match[1]))
417+
.sort((a, b) => b - a)[0];
418+
419+
if (!build) {
420+
throw new Error('latest.txt: no release with a build number in selected.json');
421+
}
422+
413423
fs.writeFileSync(
414424
path.join(__dirname, 'public', 'download', 'latest.txt'),
415-
number
425+
String(build)
416426
);
417427
};

0 commit comments

Comments
 (0)