diff --git a/__test__/unix/print.test.js b/__test__/unix/print.test.js index 78d2f4a..61a4e60 100644 --- a/__test__/unix/print.test.js +++ b/__test__/unix/print.test.js @@ -50,7 +50,7 @@ test("sends PDF file to the specific printer", () => { printer }; return print(filename, options).then(() => { - expect(execAsync).toHaveBeenCalledWith("lp", [filename, `-d ${printer}`]); + expect(execAsync).toHaveBeenCalledWith("lp", [filename, "-d", printer]); }); }); @@ -61,8 +61,10 @@ test("allows users to pass OS specific options", () => { return print(filename, options).then(() => { expect(execAsync).toHaveBeenCalledWith("lp", [ filename, - `-d ${printer}`, - "-o sides=one-sided" + "-d", + printer, + "-o", + "sides=one-sided" ]); }); }); diff --git a/__test__/win32/print.test.js b/__test__/win32/print.test.js index 5c5f40c..a7976f9 100644 --- a/__test__/win32/print.test.js +++ b/__test__/win32/print.test.js @@ -76,7 +76,8 @@ test("allows users to pass OS specific options", () => { expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [ "-print-to", printer, - '-print-settings "1,2,fit"', + "-print-settings", + '"1,2,fit"', "-silent", filename ]); diff --git a/src/unix/print.js b/src/unix/print.js index 3c37466..d33f359 100644 --- a/src/unix/print.js +++ b/src/unix/print.js @@ -13,12 +13,12 @@ const print = (pdf, options = {}) => { const { printer, unix } = options; if (printer) { - args.push(`-d ${printer}`); + args.push("-d", printer); } if (unix) { if (!Array.isArray(unix)) throw "options.unix should be an array"; - unix.map(unixArg => args.push(unixArg)); + unix.map(unixArg => args.push(...unixArg.split(" "))); } return execAsync("lp", args); diff --git a/src/win32/print.js b/src/win32/print.js index 8ab34b6..6c4f6cf 100644 --- a/src/win32/print.js +++ b/src/win32/print.js @@ -22,9 +22,10 @@ const print = (pdf, options = {}) => { } else { args.push("-print-to-default"); } + if (win32) { if (!Array.isArray(win32)) throw "options.win32 should be an array"; - win32.map(win32Arg => args.push(win32Arg)); + win32.map(win32Arg => args.push(...win32Arg.split(" "))); } args.push("-silent", pdf);