add ability to run from command line
This commit is contained in:
parent
3237ccb1ef
commit
0ca1fe8606
15
index.js
15
index.js
|
|
@ -1,5 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
const convertFromUrl = require('./lib/convertFromUrl')
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue