What is @prisma/get-platform?
The @prisma/get-platform npm package is a utility library used to detect the platform on which the Node.js process is running. It can identify the operating system and architecture, which is particularly useful for tools that need to download or use platform-specific binaries.
What are @prisma/get-platform's main functionalities?
Detecting the platform
This feature allows you to programmatically detect the current platform. The `getPlatform` function returns a promise that resolves to a string indicating the platform, such as 'darwin', 'linux', 'windows', etc.
"require('@prisma/get-platform').getPlatform().then(platform => console.log(platform))"
Detecting the platform synchronously
This feature provides a synchronous way to detect the platform. The `getPlatformSync` function returns a string directly without a promise, which can be useful in scenarios where asynchronous code is not ideal.
"const { getPlatformSync } = require('@prisma/get-platform');
const platform = getPlatformSync();
console.log(platform);"
Other packages similar to @prisma/get-platform
os
The 'os' module is a built-in Node.js module that provides operating system-related utility methods. It is similar to @prisma/get-platform in that it can be used to get information about the operating system, but it does not provide as specific platform identifiers for downloading binaries.
detect-libc
The 'detect-libc' package is used to detect the C standard library used on the system (e.g., glibc or musl). It is similar to @prisma/get-platform in that it helps in identifying system-specific characteristics important for binary compatibility, but it focuses on the C library rather than the operating system platform.
systeminformation
The 'systeminformation' package provides detailed information about the system hardware and software. While it offers a broader range of system insights compared to @prisma/get-platform, it is not specifically tailored for identifying platforms for binary downloads.
@prisma/get-platform
Platform detection used for Prisma 2 binaries.
Usage
import { getPlatform } from '@prisma/get-platform'
const platform = await getPlatform()