Skip to content

Commit

Permalink
fix(core): fix typo getParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
maxileith committed Jan 15, 2024
1 parent 876c9b4 commit e28b86b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/lib/device-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {ChildProcess} from 'child_process';

import {EventEmitter} from 'events';
import {NodePyATVDevice, NodePyATVDeviceEvent} from '../lib/index.js';
import {addRequestId, debug, execute, getParamters, parseState, removeRequestId} from './tools.js';
import {addRequestId, debug, execute, getParameters, parseState, removeRequestId} from './tools.js';
import {FakeChildProcess} from './fake-spawn.js';

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ export default class NodePyATVDeviceEvents extends EventEmitter {
this.listenerState = NodePyATVListenerState.starting;

const listenStart = new Date().getTime();
const parameters = getParamters(this.options);
const parameters = getParameters(this.options);
this.pyatv = execute(reqId, NodePyATVExecutableType.atvscript, [...parameters, 'push_updates'], this.options);
if(!this.pyatv) {
throw new Error('Unable to start listener: Unable to start atvscript');
Expand Down
8 changes: 4 additions & 4 deletions src/lib/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
NodePyATVState
} from './types.js';

import { addRequestId, getParamters, parseState, removeRequestId, request } from './tools.js';
import { addRequestId, getParameters, parseState, removeRequestId, request } from './tools.js';
import { NodePyATVDeviceEvent, NodePyATVDeviceEvents } from '../lib/index.js';
import { EventEmitter } from 'events';

Expand Down Expand Up @@ -229,7 +229,7 @@ export default class NodePyATVDevice implements EventEmitter{
const id = addRequestId();

try {
const parameters = getParamters(this.options);
const parameters = getParameters(this.options);

const result = await request(id, NodePyATVExecutableType.atvscript, [...parameters, 'playing'], this.options);
const newState = parseState(result, id, this.options);
Expand Down Expand Up @@ -401,7 +401,7 @@ export default class NodePyATVDevice implements EventEmitter{
*/
async listApps(): Promise<NodePyATVApp[]> {
const id = addRequestId();
const parameters = getParamters(this.options);
const parameters = getParameters(this.options);

const result = await request(id, NodePyATVExecutableType.atvremote, [...parameters, 'app_list'], this.options);
if(typeof result !== 'string' || !result.startsWith('App: ')) {
Expand All @@ -426,7 +426,7 @@ export default class NodePyATVDevice implements EventEmitter{

private async _pressKey(key: NodePyATVInternalKeys | string, executableType: NodePyATVExecutableType) {
const id = addRequestId();
const parameters = getParamters(this.options);
const parameters = getParameters(this.options);

const result = await request(id, executableType, [...parameters, key], this.options);
if (
Expand Down
4 changes: 2 additions & 2 deletions src/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
NodePyATVVersionResponse
} from './types.js';

import { addRequestId, debug, getParamters, removeRequestId, request } from './tools.js';
import { addRequestId, debug, getParameters, removeRequestId, request } from './tools.js';
import { NodePyATVDevice } from '../lib/index.js';

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ export default class NodePyATVInstance {
*/
public static async find (options: NodePyATVFindAndInstanceOptions = {}): Promise<NodePyATVDevice[]> {
const id = addRequestId();
const parameters = getParamters(options);
const parameters = getParameters(options);

const result = await request(id, NodePyATVExecutableType.atvscript, [...parameters, 'scan'], options);
if (typeof result !== 'object' || result.result !== 'success' || !Array.isArray(result.devices)) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export async function request(
return result.stdout;
}

export function getParamters(options: NodePyATVFindAndInstanceOptions = {}): string[] {
export function getParameters(options: NodePyATVFindAndInstanceOptions = {}): string[] {
const parameters: string[] = [];

if (options.hosts) {
Expand Down
8 changes: 4 additions & 4 deletions test/tools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import assert from 'assert';
import { addRequestId, debug, getExecutable, getParamters, parseState, removeRequestId } from '../src/lib/tools.js';
import { addRequestId, debug, getExecutable, getParameters, parseState, removeRequestId } from '../src/lib/tools.js';
import {
NodePyATVDeviceState,
NodePyATVExecutableType,
Expand Down Expand Up @@ -87,17 +87,17 @@ describe('Tools', function () {

describe('getParameters()', function () {
it('empty case', async function () {
const result = await getParamters();
const result = await getParameters();
assert.deepEqual(result, []);
});
it('easy case', async function () {
const result = await getParamters({
const result = await getParameters({
host: '192.168.178.2'
});
assert.deepEqual(result, ['-s', '192.168.178.2']);
});
it('full case', async function () {
const result = await getParamters({
const result = await getParameters({
hosts: ['192.168.178.2', '192.168.178.3'],
id: '****',
protocol: NodePyATVProtocol.mrp,
Expand Down

0 comments on commit e28b86b

Please sign in to comment.