UNPKG

@oxog/port-terminator

Version:

Cross-platform utility to terminate processes on ports with zero dependencies

48 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPlatform = getPlatform; exports.isWindows = isWindows; exports.isMacOS = isMacOS; exports.isLinux = isLinux; exports.isUnix = isUnix; exports.getShell = getShell; exports.getShellFlag = getShellFlag; const errors_1 = require("../errors"); function getPlatform() { const platform = process.platform; switch (platform) { case 'win32': return 'win32'; case 'darwin': return 'darwin'; case 'linux': return 'linux'; default: throw new errors_1.PlatformError(platform); } } function isWindows() { return getPlatform() === 'win32'; } function isMacOS() { return getPlatform() === 'darwin'; } function isLinux() { return getPlatform() === 'linux'; } function isUnix() { return isMacOS() || isLinux(); } function getShell() { if (isWindows()) { return process.env.COMSPEC || 'cmd.exe'; } return process.env.SHELL || '/bin/sh'; } function getShellFlag() { if (isWindows()) { return '/c'; } return '-c'; } //# sourceMappingURL=platform.js.map