-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
eslintNextVersion.js
32 lines (24 loc) · 973 Bytes
/
eslintNextVersion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* @fileoverview
* @author Nicholas C. Zakas
*/
//-----------------------------------------------------------------------------
// Requirements
//-----------------------------------------------------------------------------
const eleventyFetch = require("@11ty/eleventy-fetch");
//-----------------------------------------------------------------------------
// Exports
//-----------------------------------------------------------------------------
module.exports = async function() {
// if we're on the next branch, we can just read the package.json file
if (process.env.BRANCH === "next") {
return require("../../package.json").version;
}
// otherwise, we need to fetch the latest version from the GitHub API
const url = "https://raw.githubusercontent.com/eslint/eslint/next/docs/package.json";
const response = await eleventyFetch(url, {
duration: "1d",
type: "json"
});
return response.version;
}