Skip to content

Commit

Permalink
feat: add files to versions
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleytodd committed Oct 19, 2023
1 parent 9bfee60 commit e07c8c5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface VersionInfo {
end?: Date;
releaseDate: Date;
isLts: boolean;
files: string[];
}

declare function nv(alias?: string|string[], opts?: Options): Promise<VersionInfo[]>;
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ async function getLatestVersionsByCodename (now, cache, mirror) {
maintenance: s && s.maintenance && new Date(s.maintenance),
end: s && s.end && new Date(s.end),
releaseDate: new Date(ver.date),
isLts: false
isLts: false,
files: ver.files || []
}

// All versions get added to all
Expand Down
17 changes: 16 additions & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import nv from '.'
import assert from 'node:assert'

(async () => {
await nv()
const versions = await nv()
assert(versions[0].version)
assert(versions[0].major)
assert(versions[0].minor)
assert(versions[0].patch)
assert(versions[0].tag)
assert(versions[0].codename)
assert(versions[0].versionName)
assert(versions[0].start)
assert(versions[0].lts)
assert(versions[0].maintenance)
assert(versions[0].end)
assert(versions[0].releaseDate)
assert(versions[0].isLts)
assert(versions[0].files)
await nv('lts_active')
await nv(['lts_active', 'supported'])
await nv(['lts_active'], {
Expand Down
22 changes: 22 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ suite('nv', () => {
assert.strictEqual(versions[0].maintenance.toISOString(), '2020-05-19T00:00:00.000Z')
assert.strictEqual(versions[0].end.toISOString(), '2021-04-30T00:00:00.000Z')
assert.strictEqual(versions[0].isLts, true)
assert.deepStrictEqual(versions[0].files, [
'aix-ppc64',
'headers',
'linux-arm64',
'linux-armv6l',
'linux-armv7l',
'linux-ppc64le',
'linux-s390x',
'linux-x64',
'osx-x64-pkg',
'osx-x64-tar',
'src',
'sunos-x64',
'win-x64-7z',
'win-x64-exe',
'win-x64-msi',
'win-x64-zip',
'win-x86-7z',
'win-x86-exe',
'win-x86-msi',
'win-x86-zip'
])
})

test('lts', async () => {
Expand Down

0 comments on commit e07c8c5

Please sign in to comment.