|
|
@ -59,6 +59,8 @@ function selectArticle(articles, lang, searchTerms, isDeep, isApro, englishArtic
|
|
|
|
return b.lastrevid - a.lastrevid;
|
|
|
|
return b.lastrevid - a.lastrevid;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tWidth = (/chinese|korean|japanese/gi.test(lang)) ? 30 : 60;
|
|
|
|
|
|
|
|
|
|
|
|
if (len === 0) {
|
|
|
|
if (len === 0) {
|
|
|
|
if (lang === 'english') {
|
|
|
|
if (lang === 'english') {
|
|
|
|
return reject('No articles match your query.');
|
|
|
|
return reject('No articles match your query.');
|
|
|
@ -69,8 +71,8 @@ function selectArticle(articles, lang, searchTerms, isDeep, isApro, englishArtic
|
|
|
|
return resolve(sorted[0]);
|
|
|
|
return resolve(sorted[0]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
choices = sorted.map(function makeChoices(article, index) {
|
|
|
|
choices = sorted.map(function makeChoices(article, index) {
|
|
|
|
entry = ['[', chalk.yellow(index + 1), '/', chalk.yellow(len), '] ', chalk.green(article.title), ': ', chalk.gray(article.description).slice(0, 150)].join('');
|
|
|
|
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 < 150) ? entry : entry + '...';
|
|
|
|
return (article.description.length + article.title.length < tWidth) ? entry : entry + '...';
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
inquirer.prompt([{
|
|
|
|
inquirer.prompt([{
|
|
|
|