diff --git a/cli.js b/cli.js new file mode 100755 index 0000000..2652d80 --- /dev/null +++ b/cli.js @@ -0,0 +1,7 @@ +#!/usr/bin/env node +const generator = require('./index'); + +let ISBN = process.argv[2]; +let filepath = process.argv[3]; + +generator.write(filepath, ISBN); diff --git a/index.js b/index.js index bfe5ba0..4c0396f 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ function _convert(data, pretty) { module.exports = { write: function(filepath, isbn) { OL.lookup(isbn, function(err, data) { - fs.writeFileSync(filepath, _convert(data)); + fs.writeFileSync(filepath, _convert(data, true)); }); }, _convert: _convert diff --git a/package.json b/package.json index a9818b8..3d607f0 100644 --- a/package.json +++ b/package.json @@ -20,5 +20,8 @@ }, "devDependencies": { "jest": "^25.1.0" + }, + "bin": { + "generate-epub-xml": "./cli.js" } }