diff --git a/node-latex-pdf.js b/node-latex-pdf.js index 7f33043..fc07a48 100644 --- a/node-latex-pdf.js +++ b/node-latex-pdf.js @@ -1,4 +1,4 @@ -const { exec } = require('child_process'); +const { execFile } = require('child_process'); const path = require('path'); const fs = require('fs'); const os = require('os'); @@ -7,12 +7,12 @@ var selflatex = function(src_file,dest_file,callback){ // split with src file name var texname = src_file.split('/').splice(-1)[0].split('.')[0]; // compile and - exec("pdflatex -output-directory " + dest_file + " " + src_file, (err,stdout,stderr) => { + execFile("pdflatex", ["-output-directory", dest_file, src_file], (err,stdout,stderr) => { if (err) { callback(1,`pdflatex[1] error: ${err}`); }else{ // compile second time to fit the usage - exec("pdflatex -output-directory " + dest_file + " " + src_file, (err,stdout,stderr) => { + execFile("pdflatex", ["-output-directory", dest_file, src_file], (err,stdout,stderr) => { if (err) { callback(1,`pdflatex[2] error: ${err}`); }