From 80a318b8b833bfa38cf668919a9982f268a28f46 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Thu, 25 May 2023 13:11:13 +0200 Subject: [PATCH] Change PLATFORM to constant instead of function --- src/installer.ts | 4 ++-- src/utils.ts | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/installer.ts b/src/installer.ts index f44615c..a263afb 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -7,7 +7,7 @@ import {chmodSync} from 'fs'; import path from 'path'; import os from 'os'; import semver from 'semver'; -import {IS_WINDOWS, getPlatform} from './utils'; +import {IS_WINDOWS, PLATFORM} from './utils'; import {QualityOptions} from './setup-dotnet'; export interface DotnetVersion { @@ -223,7 +223,7 @@ export abstract class DotnetInstallDir { ? DotnetInstallDir.convertInstallPathToAbsolute( process.env['DOTNET_INSTALL_DIR'] ) - : DotnetInstallDir.default[getPlatform()]; + : DotnetInstallDir.default[PLATFORM]; private static convertInstallPathToAbsolute(installDir: string): string { if (path.isAbsolute(installDir)) return path.normalize(installDir); diff --git a/src/utils.ts b/src/utils.ts index d671d70..1871168 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,6 @@ export const IS_WINDOWS = process.platform === 'win32'; -export const IS_LINUX = process.platform === 'linux'; -export const getPlatform = (): 'windows' | 'linux' | 'mac' => { - if (IS_WINDOWS) return 'windows'; - if (IS_LINUX) return 'linux'; +export const PLATFORM = ((): 'windows' | 'linux' | 'mac' => { + if (process.platform === 'win32') return 'windows'; + if (process.platform === 'linux') return 'linux'; return 'mac'; -}; +})();