Skip to content

Commit 69dd05f

Browse files
authored
Merge pull request #221 from processing/latest-txt
Adding latest.txt file in build
2 parents 69caed7 + c586672 commit 69dd05f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gatsby-node.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require(`path`);
2+
const fs = require('fs');
23
const { createFilePath } = require(`gatsby-source-filesystem`);
34
const { examplePath, referencePath } = require('./src/utils/paths');
45

@@ -399,3 +400,17 @@ async function createDownload(actions, graphql) {
399400
}
400401
});
401402
}
403+
404+
/**
405+
Create the latest.txt file when the site builds.
406+
This only happens on build, not on dev.
407+
**/
408+
exports.onPostBuild = () => {
409+
const releases = require('./content/download/selected.json');
410+
const latest = releases.selectedReleases[0];
411+
const [name, number, version] = latest.split('-');
412+
fs.writeFileSync(
413+
path.join(__dirname, 'public', 'download', 'latest.txt'),
414+
number
415+
);
416+
};

0 commit comments

Comments
 (0)