Implement basic fetchFromMedium command

This commit is contained in:
Hippo 2019-10-11 16:25:52 +05:30
parent bafc64fb5b
commit ccce3dc172
2 changed files with 9 additions and 3 deletions

View file

@ -1,11 +1,13 @@
const r2 = require('r2') const r2 = require('r2')
const getPost = require('mediumexporter').getPost
/** /**
* function [fetchFromMedium] * function [fetchFromMedium]
* @returns [string] status * @returns [string] status
*/ */
const fetchFromMedium = (mediumUrl) => { const fetchFromMedium = async (mediumUrl) => {
console.info('Fetching: ' + mediumUrl); console.debug('Fetching: ' + mediumUrl);
return await getPost(mediumUrl, { returnObject: true })
}; };
/** /**

View file

@ -17,7 +17,11 @@ program.command('fetch-medium <post_url>')
.alias('fetch') .alias('fetch')
.description('fetch a Medium post') .description('fetch a Medium post')
.action((post_url) => { .action((post_url) => {
fetchFromMedium(post_url); fetchFromMedium(post_url)
.then((post) => {
console.info(`"${post.title}" fetched successfully`)
console.debug(post)
})
}); });
program.command('push-ghost <file>') program.command('push-ghost <file>')