Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added the bin that executes which-cloud
- Loading branch information
Benjamin Coe
committed
Jun 3, 2016
1 parent
33be2a3
commit 43be975
Showing
5 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env node | ||
|
||
const which = require('../') | ||
const argv = require('yargs') | ||
.usage('$0 <ip>') | ||
.help() | ||
.alias('help', 'h') | ||
.demand(1, 'you must provide an ip to lookup') | ||
.argv | ||
const ip = argv._[0] | ||
|
||
which(ip, function (err, cloud) { | ||
if (err) { | ||
console.log('unknown') | ||
process.exit(1) | ||
} else { | ||
console.log(cloud) | ||
process.exit(0) | ||
} | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* global describe, it */ | ||
|
||
require('chai').should() | ||
|
||
const exec = require('child_process').exec | ||
|
||
describe('cli', function () { | ||
it('displays help if no ip is provided', function (done) { | ||
exec('./bin/which-cloud.js', function (err, stdout, stderr) { | ||
err.message.should.match(/you must provide an ip to lookup/) | ||
return done() | ||
}) | ||
}) | ||
|
||
it('looks up an ip', function (done) { | ||
exec('./bin/which-cloud.js 94.245.97.0', function (err, stdout, stderr) { | ||
if (err) return done(err) | ||
stdout.should.match(/azure/) | ||
return done() | ||
}) | ||
}) | ||
}) |
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