Skip to content

Commit

Permalink
Fix a bug where initialization can fail when it is placed in a direct…
Browse files Browse the repository at this point in the history
…ory with a path including spaces
  • Loading branch information
shioyadan committed Jun 15, 2020
1 parent e9b52bb commit 24efa91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
{
label: "About Kuroko",
click: function(){store.trigger(store.ACTION.OPEN_DIALOG_MODAL_MESSAGE, "Kuroko Version 0.02");}
click: function(){store.trigger(store.ACTION.OPEN_DIALOG_MODAL_MESSAGE, "Kuroko Version 0.03");}
}
]
}];
Expand Down
11 changes: 8 additions & 3 deletions store.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const CHANGE = {

class Store {
constructor(externalModules) {
// They *must not* be double quoted in the following.
// They must be double quoted only for exec().
this.tmpPDF_FileName_ = __dirname + "/tmp2.pdf";
this.kurokoCLI_Bin_ = __dirname + "/kuroko-cli/kuroko-cli.exe";

Expand Down Expand Up @@ -70,7 +72,8 @@ class Store {
initKurokoCLI_() {
this.inExec = true;

exec(`${this.kurokoCLI_Bin_} -k`, (err, stdout, stderr) => {
// kurokoCLI_Bin_ must be double quoted only for exec().
exec(`"${this.kurokoCLI_Bin_}" -k`, (err, stdout, stderr) => {
console.log("kuroko-cli: " + stdout);
if (err) {
if (!fs.existsSync(this.kurokoCLI_Bin_)) {
Expand All @@ -82,7 +85,8 @@ class Store {
}

console.log("Kuroko-cli could not open a virtual printer. Now try to install the printer.");
exec(`${this.kurokoCLI_Bin_} -i`, (err, stdout, stderr) => {
// kurokoCLI_Bin_ must be double quoted only for exec().
exec(`"${this.kurokoCLI_Bin_}" -i`, (err, stdout, stderr) => {
console.log("kuroko-cli: " + stdout);
if (err) {
this.trigger(
Expand All @@ -109,7 +113,8 @@ class Store {
console.log("Start conversion");
this.inExec = true;
this.trigger(CHANGE.START_PROCESSING);
exec(`${this.kurokoCLI_Bin_} -b ${this.tmpPDF_FileName_}`, (err, stdout, stderr) => {
// tmpPDF_FileName_ must be double quoted.
exec(`"${this.kurokoCLI_Bin_}" -b "${this.tmpPDF_FileName_}"`, (err, stdout, stderr) => {
this.inExec = false;
if (!err) {
this.isPDF_Created = true;
Expand Down

0 comments on commit 24efa91

Please sign in to comment.