currently new drop detection not working!!!
This commit is contained in:
17
cli.mjs
17
cli.mjs
@ -53,6 +53,13 @@ $.api()
|
||||
if(is_git) gitCommit(changed, "pull");
|
||||
$.exit(0);
|
||||
})
|
||||
.command("only-rss", "Update RSS from known sitemap")
|
||||
.action(async function onlyRSS(){
|
||||
const { path, json }= knownSitemap();
|
||||
const status= await toRSS({ json, changed: [ path ] });
|
||||
echo({ status });
|
||||
$.exit(0);
|
||||
})
|
||||
.parse();
|
||||
|
||||
function gitCommit(files, des= "not specified"){
|
||||
@ -116,9 +123,7 @@ async function toRSS({ json, changed }){
|
||||
import { JSDOM } from "jsdom";
|
||||
/** @returns {Promise<State>} */
|
||||
async function sitemap(){
|
||||
const path= "sitemap.json";
|
||||
/** @type {Sitemap} */
|
||||
const json= s.test("-f", path) ? s.cat(path).xargs(JSON.parse) : { drops: [], articles: [] };
|
||||
const { json, path }= knownSitemap();
|
||||
await syncDrops(json);
|
||||
const [ { drop: drop_last } ]= json.drops;
|
||||
|
||||
@ -149,6 +154,12 @@ async function sitemap(){
|
||||
s.echo(JSON.stringify(json, null, "\t")).to(path);
|
||||
return { json, changed: [ path ] };
|
||||
}
|
||||
function knownSitemap(){
|
||||
const path= "sitemap.json";
|
||||
/** @type {Sitemap} */
|
||||
const json= s.test("-f", path) ? s.cat(path).xargs(JSON.parse) : { drops: [], articles: [] };
|
||||
return { json, path };
|
||||
}
|
||||
/**
|
||||
* Assumes that articles are sorted from newest to oldest
|
||||
* @param {Drop.drop} drop
|
||||
|
Reference in New Issue
Block a user