Comparing version 0.1.0 to 0.1.1
@@ -5,7 +5,7 @@ 'use strict'; | ||
let run = argv => imdbtr(argv); | ||
const run = argv => imdbtr(argv); | ||
exports.run = argv => { | ||
let movie = argv._.join(" "); | ||
const movie = argv._.join(' '); | ||
run(movie); | ||
}; |
{ | ||
"name": "imdbtr", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "IMDB on terminal", | ||
"scripts": { | ||
"test": "ava" | ||
"test": "ava", | ||
"lint": "xo", | ||
"check": "npm run test && npm run lint" | ||
}, | ||
@@ -22,7 +24,12 @@ "author": "@fernahh", | ||
"devDependencies": { | ||
"ava": "^0.11.0" | ||
"ava": "^0.11.0", | ||
"xo": "^0.12.1" | ||
}, | ||
"bin": { | ||
"imdbtr": "./bin/imdbtr" | ||
}, | ||
"xo": { | ||
"esnext": true, | ||
"space": 2 | ||
} | ||
} |
# imdbtr | ||
> IMDB on terminal | ||
[![Build Status](https://api.travis-ci.org/fernahh/imdbtr.svg?branch=master)](https://travis-ci.org/fernahh/imdbtr) | ||
> IMDb on terminal | ||
## Install | ||
``` | ||
$ npm install -g imdbtr | ||
``` | ||
## Usage | ||
``` | ||
$ imdbtr The Godfather | ||
``` | ||
## License | ||
(The MIT License) | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@@ -10,16 +10,18 @@ 'use strict'; | ||
const api = name => { | ||
if (!name) | ||
if (!name) { | ||
return false; | ||
} | ||
let movie = got(`${provider}t=${name}`, {headers}) | ||
const movie = got(`${provider}t=${name}`, {headers}) | ||
.then(response => { | ||
return JSON.parse(response.body); | ||
const result = JSON.parse(response.body); | ||
return result.Response === 'False' ? false : result; | ||
}) | ||
.catch(error => { | ||
return JSON.parse(error.body); | ||
return error.body; | ||
}); | ||
return movie; | ||
} | ||
}; | ||
module.exports = api; |
@@ -8,9 +8,10 @@ 'use strict'; | ||
const imdbtr = name => { | ||
let movie = api(name); | ||
const movie = api(name); | ||
if (!movie) | ||
return false; | ||
return movie.then(result => { | ||
if (!result) { | ||
return console.log(chalk.yellow.bold('Movie not found on IMDB :(')); | ||
} | ||
return movie.then(result => { | ||
let movieRes = ` | ||
const movieRes = ` | ||
${chalk.black.bgYellow.bold(result.Title)} (${result.Year}) on IMDb: | ||
@@ -17,0 +18,0 @@ |
@@ -7,3 +7,3 @@ 'use strict'; | ||
test('should return the name of movie when it\'s valid title', t => { | ||
let response = api('The Godfather'); | ||
const response = api('The Godfather'); | ||
@@ -17,3 +17,3 @@ return response.then(result => { | ||
test('should return error when it\'s a empty string', t => { | ||
let response = api(''); | ||
const response = api(''); | ||
@@ -24,5 +24,5 @@ t.is(response, false); | ||
test('should return error when it\'s a invalid entry', t => { | ||
let response = api(); | ||
const response = api(); | ||
t.is(response, false); | ||
}); |
3977
9
67
28
2