@prisma/get-platform
Advanced tools
Comparing version 0.0.3 to 0.1.0
@@ -6,5 +6,15 @@ /// <reference types="node" /> | ||
libssl?: string; | ||
distro?: { | ||
dist: string; | ||
codename: string; | ||
release: string; | ||
}; | ||
}; | ||
export declare function getos(): Promise<GetOSResult>; | ||
export declare function resolveUbuntu(): Promise<null | { | ||
dist: string; | ||
release: string; | ||
codename: string; | ||
}>; | ||
export declare function getLibSslVersion(): Promise<string | undefined>; | ||
export declare function getPlatform(): Promise<Platform>; |
@@ -7,5 +7,9 @@ "use strict"; | ||
const os_1 = __importDefault(require("os")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const util_1 = require("util"); | ||
const child_process_1 = require("child_process"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = debug_1.default('getos'); | ||
const readFile = util_1.promisify(fs_1.default.readFile); | ||
const exists = util_1.promisify(fs_1.default.exists); | ||
async function getos() { | ||
@@ -21,5 +25,25 @@ const platform = os_1.default.platform(); | ||
libssl: await getLibSslVersion(), | ||
distro: await resolveUbuntu(), | ||
}; | ||
} | ||
exports.getos = getos; | ||
async function resolveUbuntu() { | ||
if (await exists('/etc/lsb-release')) { | ||
const idRegex = /distrib_id=(.*)/i; | ||
const releaseRegex = /distrib_release=(.*)/i; | ||
const codenameRegex = /distrib_codename=(.*)/i; | ||
const file = await readFile('/etc/lsb-release', 'utf-8'); | ||
const idMatch = file.match(idRegex); | ||
const id = (idMatch && idMatch[1]) || null; | ||
const codenameMatch = file.match(codenameRegex); | ||
const codename = (codenameMatch && codenameMatch[1]) || null; | ||
const releaseMatch = file.match(releaseRegex); | ||
const release = (releaseMatch && releaseMatch[1]) || null; | ||
if (id && codename && release && id.toLowerCase() === 'ubuntu') { | ||
return { dist: id, release, codename }; | ||
} | ||
} | ||
return null; | ||
} | ||
exports.resolveUbuntu = resolveUbuntu; | ||
async function getLibSslVersion() { | ||
@@ -62,3 +86,3 @@ const [version, ls] = await Promise.all([ | ||
async function getPlatform() { | ||
const { platform, libssl } = await getos(); | ||
const { platform, libssl, distro } = await getos(); | ||
if (platform === 'darwin') { | ||
@@ -70,2 +94,5 @@ return 'darwin'; | ||
if (libssl === '1.0.2') { | ||
if (distro && distro.codename === 'xenial') { | ||
return 'linux-glibc-libssl1.0.2-ubuntu1604'; | ||
} | ||
return 'linux-glibc-libssl1.0.2'; | ||
@@ -72,0 +99,0 @@ } |
@@ -1,1 +0,1 @@ | ||
export declare type Platform = 'native' | 'darwin' | 'linux-glibc-libssl1.0.1' | 'linux-glibc-libssl1.0.2' | 'linux-glibc-libssl1.1.0'; | ||
export declare type Platform = 'native' | 'darwin' | 'linux-glibc-libssl1.0.1' | 'linux-glibc-libssl1.0.2' | 'linux-glibc-libssl1.0.2-ubuntu1604' | 'linux-glibc-libssl1.1.0'; |
{ | ||
"name": "@prisma/get-platform", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8147
130
2