Added option to index (specified) ignored posts. Saving index through save module, and it now notifies the user that an index has been written.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const fs = require('fs-extra');
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
const interpolate = require('../interpolate.js');
|
||||
const interpolate = require('../interpolate');
|
||||
const textToStream = require('./textToStream');
|
||||
const save = require('./save');
|
||||
|
||||
async function writeToIndex(posts, profilePaths, user) {
|
||||
const filename = interpolate(config.library.index.file, user, null, false);
|
||||
async function writeToIndex(posts, profilePaths, user, args) {
|
||||
const filepath = interpolate(config.library.index.file, user, null, false);
|
||||
const now = new Date();
|
||||
|
||||
const newAndUpdatedEntries = posts.concat(user.indexed.updated).map((post) => {
|
||||
const newAndUpdatedEntries = posts.concat(user.indexed.updated, args.indexIgnored ? user.indexed.ignored : []).map((post) => {
|
||||
const entryPost = {
|
||||
id: post.id,
|
||||
subreddit: post.subreddit,
|
||||
@@ -41,7 +42,7 @@ async function writeToIndex(posts, profilePaths, user) {
|
||||
return;
|
||||
}
|
||||
|
||||
return fs.writeFile(filename, yaml.safeDump(data));
|
||||
return save(filepath, textToStream(yaml.safeDump(data)));
|
||||
}
|
||||
|
||||
module.exports = writeToIndex;
|
||||
|
||||
Reference in New Issue
Block a user