Commit cf99cdd8 authored by Wim Yedema's avatar Wim Yedema

Use pagedjs from require

parent 7ccd8672
Pipeline #228 failed with stages
in 11 seconds
......@@ -11,9 +11,9 @@ const app = express();
const PORT = 9999;
let dir = process.cwd();
let scriptPath = path.resolve(dir, "./node_modules/pagedjs/dist/");
let currentDir = process.cwd();
let pagedjsPath = require.resolve('pagedjs')
let scriptPath = path.resolve(pagedjsPath, '../../dist')
const PDF_SETTINGS = {
printBackground: true,
......@@ -42,12 +42,13 @@ class Printer extends EventEmitter {
}
async serve(input) {
let relativePath = path.resolve(dir, input);
let relativePath = path.resolve(currentDir, input);
let dirname = path.dirname(relativePath);
app.use("/print", express.static(dirname))
let scriptPath = path.resolve(dir, "./node_modules/pagedjs/dist/");
let pagedjsPath = require.resolve('pagedjs')
let scriptPath = path.resolve(pagedjsPath, '../../dist')
app.use("/polyfill", express.static(scriptPath))
app.set('port', process.env.PORT || 0);
......@@ -74,7 +75,7 @@ class Printer extends EventEmitter {
let server = await this.serve(input);
let port = server.address().port;
let relativePath = path.resolve(dir, input);
let relativePath = path.resolve(currentDir, input);
let basename = path.basename(relativePath);
await page.goto(`http://localhost:${port}/print/${basename}`)
......
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