Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Apr 9, 2024
1 parent fff9c93 commit ea5d442
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
18 changes: 15 additions & 3 deletions lib/commands/record-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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`);
Expand Down

0 comments on commit ea5d442

Please sign in to comment.