Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Commit

Permalink
fix: check if stdout is bytearray before processing
Browse files Browse the repository at this point in the history
  • Loading branch information
oae committed Apr 13, 2019
1 parent cf43fba commit 32c9f95
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions windowUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ var getIdInDec = metaWindow => {
`xdotool search --onlyvisible --maxdepth=2 --pid ${getPid(metaWindow)}`,
);

return ByteArray.toString(stdout).split('\n')[0];
if (stdout instanceof Uint8Array) {
return ByteArray.toString(stdout)
.split('\n')[0]
.trim();
}

return stdout
.toString()
.split('\n')[0]
.trim();
};

var getIdInHex = metaWindow => {
Expand Down Expand Up @@ -66,7 +75,13 @@ var windowExists = (pid, idInDec) => {
`xdotool search --maxdepth=2 --pid ${pid}`,
);

const windowList = ByteArray.toString(stdout);
let windowList = ByteArray.toString(stdout);

if (stdout instanceof Uint8Array) {
windowList = ByteArray.toString(stdout);
} else {
windowList = stdout.toString();
}

return windowList.indexOf(idInDec) >= 0;
};
Expand Down

0 comments on commit 32c9f95

Please sign in to comment.