mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-21 21:08:05 +08:00
Add platform info utilities to @actions/core (#1551)
* Introduce platform utilities into @actions/core * Add tests for the platform helper * Update README.md * Update README.md with more details
This commit is contained in:
29
packages/core/__tests__/platform.test.ts
Normal file
29
packages/core/__tests__/platform.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import os from 'os'
|
||||
import {platform} from '../src/core'
|
||||
|
||||
describe('getInfo', () => {
|
||||
it('returns the platform info', async () => {
|
||||
const info = await platform.getDetails()
|
||||
expect(info).toEqual({
|
||||
name: expect.any(String),
|
||||
platform: expect.any(String),
|
||||
arch: expect.any(String),
|
||||
version: expect.any(String),
|
||||
isWindows: expect.any(Boolean),
|
||||
isMacOS: expect.any(Boolean),
|
||||
isLinux: expect.any(Boolean)
|
||||
})
|
||||
})
|
||||
|
||||
it('returns the platform info with the correct name', async () => {
|
||||
const isWindows = os.platform() === 'win32'
|
||||
const isMacOS = os.platform() === 'darwin'
|
||||
const isLinux = os.platform() === 'linux'
|
||||
|
||||
const info = await platform.getDetails()
|
||||
expect(info.platform).toEqual(os.platform())
|
||||
expect(info.isWindows).toEqual(isWindows)
|
||||
expect(info.isMacOS).toEqual(isMacOS)
|
||||
expect(info.isLinux).toEqual(isLinux)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user