Skip to content

Commit aacf5ac

Browse files
committed
avoid nullish coalescing operators
1 parent 53a5213 commit aacf5ac

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function run() {
8282
mode === "image" ? "android-screenshot" : "android-video"
8383

8484
const outPath = normalize(
85-
sanitizeFilename(filename, extension) ??
85+
sanitizeFilename(filename, extension) ||
8686
generateFilename(defaultFilename, extension),
8787
)
8888

src/getDevice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports.getDevice = async () => {
4848
*/
4949
function parseDeviceLine(line) {
5050
const [id, _type, ...properties] = line.split(/\s+/)
51-
const model = properties.find((p) => p.startsWith("model:"))?.split(":")[1]
51+
const model = (properties.find((p) => p.startsWith("model:")) || "").split(":")[1]
5252
const isUSB = properties.some((p) => p.startsWith("usb:"))
5353
return { id, model, isUSB }
5454
}

src/keyboardInput.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports.popKeyboardContext = () => {
3939
}
4040

4141
function handleEscape() {
42-
const handle = handlers[handlers.length - 1]?.handleEscape
42+
const handle = (handlers[handlers.length - 1] || {}).handleEscape
4343
if (handle) {
4444
handle()
4545
} else {
@@ -52,7 +52,10 @@ process.stdin.addListener("data", (key) => {
5252
if (ESCAPE_KEYS[char]) {
5353
handleEscape()
5454
} else {
55-
handlers[handlers.length - 1]?.handleKeyPress?.(char)
55+
const handle = (handlers[handlers.length - 1] || {}).handleKeyPress
56+
if (handle) {
57+
handle(char)
58+
}
5659
}
5760
})
5861

0 commit comments

Comments
 (0)