|
|
|
@ -53,13 +53,12 @@ function selectArticle(articles, lang, searchTerms, isDeep, isApro, englishArtic
|
|
|
|
|
return new Promise(function makePromise(resolve, reject) {
|
|
|
|
|
var len = articles.length;
|
|
|
|
|
var choices;
|
|
|
|
|
var entry;
|
|
|
|
|
|
|
|
|
|
var sorted = articles.sort(function sortSpecialLast(a, b) {
|
|
|
|
|
return b.lastrevid - a.lastrevid;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var tWidth = (/chinese|korean|japanese/gi.test(lang)) ? 30 : 60;
|
|
|
|
|
var tWidth = (/chinese|korean|japanese/gi.test(lang)) ? 40 : 80;
|
|
|
|
|
|
|
|
|
|
if (len === 0) {
|
|
|
|
|
if (lang === 'english') {
|
|
|
|
@ -71,8 +70,8 @@ function selectArticle(articles, lang, searchTerms, isDeep, isApro, englishArtic
|
|
|
|
|
return resolve(sorted[0]);
|
|
|
|
|
} else {
|
|
|
|
|
choices = sorted.map(function makeChoices(article, index) {
|
|
|
|
|
entry = ['[', chalk.yellow(index + 1), '/', chalk.yellow(len), '] ', chalk.green(article.title), ': ', chalk.gray(article.description).substr(0, tWidth)].join('').replace('\n', '');
|
|
|
|
|
return (article.description.length + article.title.length < tWidth) ? entry : entry + '...';
|
|
|
|
|
var entry = ['[', chalk.yellow(index + 1), '/', chalk.yellow(len), '] ', chalk.green(article.title), ': ', chalk.gray(article.description.substr(0, tWidth))].join('').replace(/\\?\n/g, '');
|
|
|
|
|
return (article.description.length + article.title.length < tWidth) ? entry : entry + chalk.gray('..');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
inquirer.prompt([{
|
|
|
|
|