chore: update utils
This commit is contained in:
parent
e66168660a
commit
776616f45d
11
src/utils/getOS.ts
Normal file
11
src/utils/getOS.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { OS } from '../types';
|
||||
|
||||
// slice to get the last part of the url that includes the os
|
||||
export const getOS = (url: string): OS =>
|
||||
url?.slice(46).includes('darwin')
|
||||
? 'darwin'
|
||||
: url?.slice(46).includes('linux')
|
||||
? 'linux'
|
||||
: url?.slice(46).includes('windows')
|
||||
? 'windows'
|
||||
: 'mobile';
|
@ -5,6 +5,7 @@ export { fetchXMLData } from './fetchXMLData';
|
||||
export { getChecksum } from './getChecksum';
|
||||
export { getKebabCaseFromName } from './getKebabCaseFromName';
|
||||
export { getLatestBinaryURL } from './getLatestBinaryURL';
|
||||
export { getOS } from './getOS';
|
||||
export { getParsedDate } from './getParsedDate';
|
||||
export { getProgrammingLanguageName } from './getProgrammingLanguageName';
|
||||
export { getReleaseArch } from './getReleaseArch';
|
||||
@ -16,4 +17,8 @@ export { getReleaseSize } from './getReleaseSize';
|
||||
export { getReleaseURL } from './getReleaseURL';
|
||||
export { getSignatureURL } from './getSignatureURL';
|
||||
export { getSortedReleases } from './getSortedReleases';
|
||||
export { isDarwinPrimaryRelease } from './isDarwinPrimaryRelease';
|
||||
export { isLinuxPrimaryRelease } from './isLinuxPrimaryRelease';
|
||||
export { isMobilePrimaryRelease } from './isMobilePrimaryRelease';
|
||||
export { isWindowsPrimaryRelease } from './isWindowsPrimaryRelease';
|
||||
export { mapReleasesData } from './mapReleasesData';
|
||||
|
8
src/utils/isDarwinPrimaryRelease.ts
Normal file
8
src/utils/isDarwinPrimaryRelease.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { OS, ReleaseData } from '../types';
|
||||
|
||||
export const isDarwinPrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) =>
|
||||
os === 'darwin' &&
|
||||
data
|
||||
.slice(0, 2) // get latest build to filter on
|
||||
.filter((e: ReleaseData) => e.arch === '64-bit')
|
||||
.includes(r);
|
8
src/utils/isLinuxPrimaryRelease.ts
Normal file
8
src/utils/isLinuxPrimaryRelease.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { OS, ReleaseData } from '../types';
|
||||
|
||||
export const isLinuxPrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) =>
|
||||
os === 'linux' &&
|
||||
data
|
||||
.slice(0, 12) // get latest build to filter on
|
||||
.filter((e: ReleaseData) => e.arch === '64-bit')
|
||||
.includes(r);
|
8
src/utils/isMobilePrimaryRelease.ts
Normal file
8
src/utils/isMobilePrimaryRelease.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { OS, ReleaseData } from '../types';
|
||||
|
||||
export const isMobilePrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) =>
|
||||
os === 'mobile' &&
|
||||
data
|
||||
.filter((e: ReleaseData) => e.arch === 'all')
|
||||
.slice(0, 1) // get latest build
|
||||
.includes(r);
|
8
src/utils/isWindowsPrimaryRelease.ts
Normal file
8
src/utils/isWindowsPrimaryRelease.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { OS, ReleaseData } from '../types';
|
||||
|
||||
export const isWindowsPrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) =>
|
||||
os === 'windows' &&
|
||||
data
|
||||
.slice(0, 6) // get latest build to filter on
|
||||
.filter((e: ReleaseData) => e.kind === 'Installer' && e.arch === '64-bit')
|
||||
.includes(r);
|
Loading…
Reference in New Issue
Block a user