Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed May 14, 2016
1 parent 643a64c commit 8a7db20
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
1 change: 0 additions & 1 deletion .node-version

This file was deleted.

4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
src
.*
LICENSE
test
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5
v6
27 changes: 6 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
"name": "anime-dl-cli",
"version": "1.1.2",
"description": "CLI for show and download anime from jkanime.net",
"main": "lib",
"main": "src",
"scripts": {
"prepublish": "npm run build -s",
"prebuild": "npm run lint -s && npm run clean -s",
"build": "babel src --out-dir lib --source-maps",
"lint": "eslint src && eslint test",
"clean": "rimraf lib"
"prepublish": "eslint src"
},
"engines": {
"node": ">=0.12"
"node": ">=4"
},
"bin": {
"anime-dl": "lib/index.js"
"anime-dl": "src/index.js"
},
"preferGlobal": true,
"repository": {
Expand All @@ -35,14 +31,11 @@
"anime-dl": "^3.0.0",
"chalk": "^1.1.3",
"commander": "^2.9.0",
"ora": "^0.2.1",
"update-notifier": "^0.7.0"
},
"devDependencies": {
"babel-cli": "^6.8.0",
"babel-core": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"eslint": "^2.10.0",
"rimraf": "^2.5.2"
"eslint": "^2.10.1"
},
"eslintConfig": {
"env": {
Expand All @@ -51,9 +44,6 @@
"mocha": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
2,
Expand All @@ -75,10 +65,5 @@
0
]
}
},
"babel": {
"presets": [
"es2015"
]
}
}
20 changes: 13 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

'use strict';

import program from 'commander';
import animeDl from 'anime-dl';
import chalk from 'chalk';
import updateNotifier from 'update-notifier';
import pkg from '../package.json';
const program = require('commander');
const animeDl = require('anime-dl');
const chalk = require('chalk');
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');
const ora = require('ora');

updateNotifier({pkg}).notify();

Expand All @@ -19,14 +20,19 @@ program
.parse(process.argv);

if (program.anime && program.chapter) {
console.log(chalk.green('Searching...'));
const spinner = ora('Searching...');
spinner.start();
animeDl.getLinksByNameAndChapter(program.anime, program.chapter).then((data) => {
spinner.stop();
if (data.urls.length === 0) return console.log(chalk.red('No links found'));
console.log(chalk.green('Run any of these links in your video player'));
for (let url of data.urls) {
console.log(chalk.green(url));
}
}).catch((err) => console.log(chalk.red(`Error: ${err.message}`)));
}).catch((err) => {
spinner.stop();
console.log(chalk.red(`Error: ${err.message}`));
});
} else {
program.help();
}

0 comments on commit 8a7db20

Please sign in to comment.