mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
+20
-24
@@ -16,30 +16,24 @@ const scraper = require('../services/scraper');
|
||||
const inquirer = require('inquirer');
|
||||
|
||||
// Register the shutdown criteria.
|
||||
util.onshutdown([
|
||||
() => mongoose.disconnect()
|
||||
]);
|
||||
util.onshutdown([() => mongoose.disconnect()]);
|
||||
|
||||
/**
|
||||
* Lists all the assets registered in the database.
|
||||
*/
|
||||
async function listAssets() {
|
||||
try {
|
||||
let assets = await AssetModel.find({}).sort({'created_at': 1});
|
||||
let assets = await AssetModel.find({}).sort({ created_at: 1 });
|
||||
|
||||
let table = new Table({
|
||||
head: [
|
||||
'ID',
|
||||
'Title',
|
||||
'URL'
|
||||
]
|
||||
head: ['ID', 'Title', 'URL'],
|
||||
});
|
||||
|
||||
assets.forEach((asset) => {
|
||||
assets.forEach(asset => {
|
||||
table.push([
|
||||
asset.id,
|
||||
asset.title ? asset.title : '',
|
||||
asset.url ? asset.url : ''
|
||||
asset.url ? asset.url : '',
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -61,13 +55,13 @@ async function refreshAssets(ageString) {
|
||||
$or: [
|
||||
{
|
||||
scraped: {
|
||||
$lte: age
|
||||
}
|
||||
$lte: age,
|
||||
},
|
||||
},
|
||||
{
|
||||
scraped: null
|
||||
}
|
||||
]
|
||||
scraped: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Queue all the assets for scraping.
|
||||
@@ -95,7 +89,6 @@ async function updateURL(assetID, assetURL) {
|
||||
|
||||
async function merge(srcID, dstID) {
|
||||
try {
|
||||
|
||||
// Grab the assets...
|
||||
let [srcAsset, dstAsset] = await AssetsService.findByIDs([srcID, dstID]);
|
||||
if (!srcAsset || !dstAsset) {
|
||||
@@ -103,21 +96,22 @@ async function merge(srcID, dstID) {
|
||||
}
|
||||
|
||||
// Count the affected resources...
|
||||
let srcCommentCount = await CommentModel.find({asset_id: srcID}).count();
|
||||
let srcCommentCount = await CommentModel.find({ asset_id: srcID }).count();
|
||||
|
||||
console.log(`Now going to update ${srcCommentCount} comments and delete the source Asset[${srcID}].`);
|
||||
console.log(
|
||||
`Now going to update ${srcCommentCount} comments and delete the source Asset[${srcID}].`
|
||||
);
|
||||
|
||||
let {confirm} = await inquirer.prompt([
|
||||
let { confirm } = await inquirer.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'confirm',
|
||||
message: 'Proceed with merge',
|
||||
default: false
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
]);
|
||||
|
||||
if (confirm) {
|
||||
|
||||
// Perform the merge!
|
||||
await AssetsService.merge(srcID, dstID);
|
||||
} else {
|
||||
@@ -152,7 +146,9 @@ program
|
||||
|
||||
program
|
||||
.command('merge <srcID> <dstID>')
|
||||
.description('merges two assets together by moving comments from src to dst and deleting the src asset')
|
||||
.description(
|
||||
'merges two assets together by moving comments from src to dst and deleting the src asset'
|
||||
)
|
||||
.action(merge);
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
Reference in New Issue
Block a user