Call librefoffice in nodejs

I tried to conver the office to pdf by librefoffice,

const exec = require('child_process').exec;
const child = exec('soffice --headless --convert-to pdf x.docx',
  (error, stdout, stderr) => {
	// now the file x.pdf may not be generated yet.
});

However it seems that the soffice --convert-to will not block the process, then I wonder if it is possible to wait until the job complete?