forked from szenius/set-timezone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (34 loc) · 947 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { platform, stdout } from 'process';
import { getInput, setFailed } from '@actions/core';
import { execa } from 'execa';
const execCommand = async (file, args) => execa(file, args).stdout.pipe(stdout);
const setTimezone = async () => {
try {
switch (platform) {
case 'linux':
await execCommand('sudo', [
'timedatectl',
'set-timezone',
getInput('timezoneLinux'),
]);
break;
case 'darwin':
await execCommand('sudo', [
'systemsetup',
'-settimezone',
getInput('timezoneMacos'),
]);
break;
case 'win32':
await execCommand('tzutil', ['/s', getInput('timezoneWindows')]);
break;
default:
setFailed(
`Platform ${platform} not supported; Only linux, darwin or win32 are supported now`
);
}
} catch (error) {
setFailed(error.message);
}
};
setTimezone();