-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·34 lines (28 loc) · 662 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·34 lines (28 loc) · 662 Bytes
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
#!/usr/bin/env node
import process from 'node:process';
import logSymbols from 'log-symbols';
import meow from 'meow';
import isOnline from 'is-online';
const cli = meow(`
Usage
$ is-online
Options
--timeout Seconds to wait for a server to respond (Default: 5)
Example
$ is-online
${logSymbols.success} Online
Exit code 0 if online and 1 if offline.
`, {
importMeta: import.meta,
flags: {
timeout: {
type: 'number',
default: 5,
},
},
});
const online = await isOnline({
timeout: cli.flags.timeout * 1000,
});
console.log(online ? `${logSymbols.success} Online` : `${logSymbols.error} Offline`);
process.exit(online ? 0 : 1);