Skip to content

Commit

Permalink
Adds npmignore, Optimize screenshot, Rearrange index fns
Browse files Browse the repository at this point in the history
  • Loading branch information
Praseetha-KR committed Dec 27, 2016
1 parent 62c3dc9 commit bc195e3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
screenshot_*
.editorconfig
.eslintrc.json
.gitattributes
.travis.yml
_config.yml
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ $ getmyip
-V, --version output the version number
```

<div style="text-align: center">
<img src="./screenshot_getmyip.png" width="600" />
</div>
<img src="https://raw.githubusercontent.com/Praseetha-KR/getmyip/master/screenshot_getmyip.png" width="600" />


## License

Expand Down
24 changes: 12 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,13 @@ const fetch = require('node-fetch');
const program = require('commander');
const pkg = require('./package.json');

program
.version(pkg.version)
.description('`getmyip` command prints your current IP')
.usage('[options]')
.option('-v, --verbose', 'Show more details')
.parse(process.argv);

const URL = 'http://ipinfo.io';
const OPTIONS = {
headers: {
'Accept': 'application/json'
}
};

function objToStr(obj) {
const keyval = Object.keys(obj).map(key => `${key}\t: ${obj[key]}`);
return keyval.join('\n');
}

function ProcessVerboseResponse(response) {
const res = {
ip: response.ip,
Expand All @@ -36,6 +24,18 @@ function ProcessVerboseResponse(response) {
return objToStr(res);
}

function objToStr(obj) {
const keyval = Object.keys(obj).map(key => `${key}\t: ${obj[key]}`);
return keyval.join('\n');
}

program
.version(pkg.version)
.description('`getmyip` command prints your current IP')
.usage('[options]')
.option('-v, --verbose', 'Show more details')
.parse(process.argv);

fetch(URL, OPTIONS)
.then(res => res.json())
.then(response => {
Expand Down
Binary file modified screenshot_getmyip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bc195e3

Please sign in to comment.