-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
038f84e
commit 5c66dfa
Showing
6 changed files
with
32 additions
and
34 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
const meow = require('meow'); | ||
const logSymbols = require('log-symbols'); | ||
const isUp = require('is-up'); | ||
const prependHttp = require('prepend-http'); | ||
import process from 'node:process'; | ||
import meow from 'meow'; | ||
import logSymbols from 'log-symbols'; | ||
import isUp from 'is-up'; | ||
import prependHttp from 'prepend-http'; | ||
|
||
const cli = meow(` | ||
Example | ||
$ is-up sindresorhus.com | ||
${logSymbols.success} Up | ||
Exits with code 0 if up and 2 if down | ||
`); | ||
`, { | ||
importMeta: import.meta, | ||
}); | ||
|
||
if (cli.input.length === 0) { | ||
console.error('Specify a URL'); | ||
process.exit(1); | ||
process.exitCode = 1; | ||
} else { | ||
(async () => { | ||
const up = await isUp(prependHttp(cli.input[0])); | ||
console.log(up ? `${logSymbols.success} Up` : `${logSymbols.error} Down`); | ||
process.exitCode = up ? 0 : 2; | ||
})(); | ||
} | ||
|
||
(async () => { | ||
const up = await isUp(prependHttp(cli.input[0])); | ||
console.log(up ? `${logSymbols.success} Up` : `${logSymbols.error} Down`); | ||
process.exitCode = up ? 0 : 2; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
|
||
## Install | ||
|
||
``` | ||
$ npm install --global is-up-cli | ||
```sh | ||
npm install --global is-up-cli | ||
``` | ||
|
||
## Usage | ||
|