Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function core(options) {
// instantiate our data object, to be expanded upon
const data = {};

Object.keys(versions).map(async (version) => {
for (const version of Object.keys(versions)) {
// keep the pre-release identifiers, otherwise every Alpha release (like
// `v27.0.0-alpha.0.0.0`) would be coerced into `v27.0.0`
const versionSemver = semver.coerce(versions[version].version, {
Expand Down Expand Up @@ -133,10 +133,8 @@ async function core(options) {
data[name].support.phases.dates.end = schedule[name]?.end ?? undefined;
}
data[name].support.phases.current =
(await determineCurrentReleasePhase(
now,
data[name].support.phases.dates,
)) ?? {};
determineCurrentReleasePhase(now, data[name].support.phases.dates) ??
{};
}

// this is a slightly inefficient way to do this but it's also easy
Expand Down Expand Up @@ -194,12 +192,12 @@ async function core(options) {

data[name].releases[`v${versionSemver.version}`].security.isSecurity =
versions[version].security ?? false;
});
}

return data;
}

async function determineCurrentReleasePhase(now, dates = {}) {
function determineCurrentReleasePhase(now, dates = {}) {
// we set set this up to enable custom `now` passing, since passing an ISO
// const usableNow = DateTime.fromISO(now)

Expand Down
13 changes: 13 additions & 0 deletions core/test/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { rejects } = require('node:assert');
const nodevu = require('../index');
const { describe, it } = require('node:test');

describe('errors while building the data', async () => {
it('should reject when index.json has a version that cannot be parsed', async () => {
const index = [{ version: 'not-a-version', files: [] }];
const fetch = async (url) =>
Response.json(url.endsWith('schedule.json') ? {} : index);

await rejects(nodevu({ fetch, now: '2024-01-01T00:00:00.000Z' }));
});
});
Loading