add ability to run from command line

This commit is contained in:
almenon 2019-12-22 15:11:27 -08:00
parent 3237ccb1ef
commit 0ca1fe8606
1 changed files with 14 additions and 1 deletions

View File

@ -1,5 +1,18 @@
'use strict'; 'use strict';
const convertFromUrl = require('./lib/convertFromUrl')
module.exports = { module.exports = {
convertFromUrl: require('./lib/convertFromUrl') convertFromUrl
}
// if run as cmd utility
if (typeof require !== 'undefined' && require.main === module) {
if(process.argv.length < 3){
console.log('What url to convert?')
return
}
convertFromUrl(process.argv[2]).then(function (markdown) {
console.log(markdown); //=> Markdown content of medium post
});
} }