@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
46 lines • 1.79 kB
JavaScript
// SPDX-License-Identifier: Apache-2.0
import { InjectTokens } from '../../core/dependency-injection/inject-tokens.js';
import { container } from 'tsyringe-neo';
/**
* Utility class for determining the operating system platform.
* Provides methods to check if the current OS is Windows, Linux, or macOS.
*/
export class OperatingSystem {
static OS_WIN32 = 'win32';
static OS_DARWIN = 'darwin';
static OS_LINUX = 'linux';
/**
* Returns true if the Node.js `process.platform` is win32, false otherwise.
*/
static isWin32() {
return OperatingSystem.getPlatform() === OperatingSystem.OS_WIN32;
}
/**
* Returns true if the Node.js `process.platform` is linux, false otherwise.
*/
static isLinux() {
return OperatingSystem.getPlatform() === OperatingSystem.OS_LINUX;
}
/**
* Returns true if the Node.js `process.platform` is darwin, false otherwise.
*/
static isDarwin() {
return OperatingSystem.getPlatform() === OperatingSystem.OS_DARWIN;
}
/**
* Returns the current Node.js `process.platform` value as a string.
* This should only be used for logging or error messages to indicate the detected platform.
*/
static getPlatform() {
return container.resolve(InjectTokens.OsPlatform);
}
/**
* Returns a formatted platform string for use in constructing download URLs or file paths.
* For Windows, it returns 'windows' instead of 'win32' to match common naming conventions in download URLs.
* For other platforms, it returns the original `process.platform` value.
*/
static getFormattedPlatform() {
return this.isWin32() ? 'windows' : OperatingSystem.getPlatform();
}
}
//# sourceMappingURL=operating-system.js.map