Commit 9cfe48eb authored by Fred Chasen's avatar Fred Chasen

Fix paths to resolve from process location, update npm instructions

parent 8db4547e
Pipeline #608 skipped
...@@ -5,7 +5,7 @@ Render Html to PDFs using [Vivliostyle.js](https://github.com/vivliostyle/vivlio ...@@ -5,7 +5,7 @@ Render Html to PDFs using [Vivliostyle.js](https://github.com/vivliostyle/vivlio
## Installation ## Installation
``` ```
npm install -g https://gitlab.coko.foundation/fchasen/vivliostyle-electron.git npm install -g git+ssh://git@gitlab.coko.foundation:fchasen/vivliostyle-electron.git
``` ```
## Generating a PDF ## Generating a PDF
......
...@@ -21,9 +21,10 @@ program ...@@ -21,9 +21,10 @@ program
.parse(process.argv); .parse(process.argv);
var input = program.inputs || program.args[0]; var input = program.inputs || program.args[0];
var relativePath = path.relative(__dirname, input); var dir = process.cwd();
var relativePath = path.resolve(dir, input);
var output = program.output || './' + path.basename(input).replace('.xhtml', '.pdf').replace('.html', '.pdf'); var output = program.output ? path.resolve(dir, program.output) : './' + path.basename(input).replace('.xhtml', '.pdf').replace('.html', '.pdf');
var render; var render;
...@@ -31,6 +32,9 @@ var hyphenate; ...@@ -31,6 +32,9 @@ var hyphenate;
var tmpPath; var tmpPath;
if (path.extname(relativePath) != ('.html' || '.xhtml')) {
return console.error("Must pass a html or xhtml file as input");
}
if (program.hyphenate) { if (program.hyphenate) {
tmpPath = relativePath.replace(".xhtml", ".hyphenated.xhtml").replace(".html", ".hyphenated.html"); tmpPath = relativePath.replace(".xhtml", ".hyphenated.xhtml").replace(".html", ".hyphenated.html");
...@@ -47,7 +51,7 @@ renderer = new Renderer(tmpPath || input, output, { ...@@ -47,7 +51,7 @@ renderer = new Renderer(tmpPath || input, output, {
height: program.height, height: program.height,
debug: program.debug debug: program.debug
}).then(function (result) { }).then(function (result) {
if (tmpPath) { if (tmpPath && tmpPath != relativePath) {
fs.unlinkSync(tmpPath); fs.unlinkSync(tmpPath);
} }
}).catch(function (err) { }).catch(function (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment