mirror of
https://github.com/actions/setup-python.git
synced 2026-01-23 06:58:54 +08:00
Add OS info to the error message
This commit is contained in:
parent
1aafadcfb9
commit
6c87c81bbd
3 changed files with 104 additions and 4 deletions
55
src/utils.ts
55
src/utils.ts
|
|
@ -142,3 +142,58 @@ export function logWarning(message: string): void {
|
|||
const warningPrefix = '[warning]';
|
||||
core.info(`${warningPrefix}${message}`);
|
||||
}
|
||||
|
||||
async function getWindowsInfo() {
|
||||
const {stdout} = await exec.getExecOutput(
|
||||
'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"',
|
||||
undefined,
|
||||
{
|
||||
silent: true
|
||||
}
|
||||
);
|
||||
|
||||
const windowsVersion = stdout.trim().split(' ')[3];
|
||||
|
||||
return `Windows ${windowsVersion}`;
|
||||
}
|
||||
|
||||
async function getMacOSInfo() {
|
||||
const {stdout} = await exec.getExecOutput(
|
||||
'sw_vers',
|
||||
['-productVersion'],
|
||||
{
|
||||
silent: true
|
||||
}
|
||||
);
|
||||
|
||||
const macOSVersion = stdout.trim();
|
||||
|
||||
return `macOS ${macOSVersion}`;
|
||||
}
|
||||
|
||||
async function getLinuxInfo() {
|
||||
const {stdout} = await exec.getExecOutput(
|
||||
'lsb_release',
|
||||
['-i', '-r', '-s'],
|
||||
{
|
||||
silent: true
|
||||
}
|
||||
);
|
||||
|
||||
const [osName, osVersion] = stdout.trim().split('\n');
|
||||
|
||||
return `${osName} ${osVersion}`;
|
||||
}
|
||||
|
||||
export async function getOSInfo() {
|
||||
let osInfo;
|
||||
if (IS_WINDOWS){
|
||||
osInfo = await getWindowsInfo();
|
||||
} else if (IS_LINUX) {
|
||||
osInfo = await getLinuxInfo();
|
||||
} else if (IS_MAC) {
|
||||
osInfo = await getMacOSInfo();
|
||||
}
|
||||
|
||||
return osInfo;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue