From ea5d44212ada689ae61ef299273e496ef69df81b Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Tue, 9 Apr 2024 20:07:09 +0200 Subject: [PATCH] fix types --- .github/workflows/functional-test.yml | 2 +- lib/commands/record-screen.js | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/functional-test.yml b/.github/workflows/functional-test.yml index 79f3235..b3de4af 100644 --- a/.github/workflows/functional-test.yml +++ b/.github/workflows/functional-test.yml @@ -26,7 +26,7 @@ jobs: node-version: lts/* check-latest: true - run: | - npm install -g appium@next + npm install -g appium npm install name: Install dev dependencies - run: | diff --git a/lib/commands/record-screen.js b/lib/commands/record-screen.js index f1f7e1e..30c271f 100644 --- a/lib/commands/record-screen.js +++ b/lib/commands/record-screen.js @@ -48,6 +48,12 @@ process.on('exit', () => { }); class ScreenRecorder { + /** + * @param {string} udid + * @param {string} videoPath + * @param {import('@appium/types').AppiumLogger} log + * @param {{codec?: string, display?: string, mask?: string, timeLimit?: string|number}} [opts={}] + */ constructor (udid, videoPath, log, opts = {}) { this.log = log; this._process = null; @@ -56,7 +62,13 @@ class ScreenRecorder { this._codec = opts.codec; this._display = opts.display; this._mask = opts.mask; - this._timeLimitMs = opts.timeLimit > 0 ? opts.timeLimit * 1000 : DEFAULT_TIME_LIMIT_MS; + this._timeLimitMs = DEFAULT_TIME_LIMIT_MS; + if (opts.timeLimit) { + const timeLimitMs = parseInt(String(opts.timeLimit), 10); + if (timeLimitMs > 0) { + this._timeLimitMs = timeLimitMs * 1000; + } + } this._timer = null; } @@ -76,7 +88,7 @@ class ScreenRecorder { if (this.isRunning) { this.log.debug('Force-stopping the currently running video recording'); try { - await this._process.stop('SIGKILL'); + await /** @type {import('teen_process').SubProcess} */ (this._process).stop('SIGKILL'); } catch (ign) {} } this._process = null; @@ -166,7 +178,7 @@ class ScreenRecorder { } try { - await this._process.stop('SIGINT', PROCESS_SHUTDOWN_TIMEOUT_MS); + await /** @type {import('teen_process').SubProcess} */ (this._process).stop('SIGINT', PROCESS_SHUTDOWN_TIMEOUT_MS); } catch (e) { await this._enforceTermination(); throw new Error(`Screen recording has failed to stop after ${PROCESS_SHUTDOWN_TIMEOUT_MS}ms`);