Skip to content

Commit 8530771

Browse files
committed
[DDW-1081] Use wrappedFind instead of find everywhere
1 parent 20daecb commit 8530771

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

source/main/cardano/CardanoSelfnodeLauncher.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { spawn } from 'child_process';
2-
import find from 'find-process';
32
import path from 'path';
43
import fs, { WriteStream } from 'fs';
54
import which from 'which';
@@ -9,6 +8,7 @@ import type { Process } from '../utils/processes';
98
import type { CardanoNodeProcessNames } from '../../common/types/cardano-node.types';
109
import { environment } from '../environment';
1110
import { logger } from '../utils/logging';
11+
import { wrappedFind } from '../utils/processes';
1212

1313
export type SelfnodeOptions = {
1414
selfnodeBin: string;
@@ -25,7 +25,6 @@ export type Selfnode = {
2525
connected: boolean;
2626
};
2727
let mockTokenMetadataServer = null;
28-
const platform = String(environment.platform);
2928
const CARDANO_WALLET_PORT = 8088;
3029
const CARDANO_WALLET_START_TIMEOUT = 60 * 1000; // 60 seconds | unit: milliseconds
3130

@@ -69,7 +68,10 @@ export async function CardanoSelfnodeLauncher(
6968
mockTokenMetadataServerLogFile
7069
);
7170
// @ts-ignore ts-migrate(2322) FIXME: Type '{ pid: number; ppid?: number; uid?: number; ... Remove this comment to see the full error message
72-
const processList: Array<Process> = await find('port', CARDANO_WALLET_PORT);
71+
const processList: Array<Process> = await wrappedFind(
72+
'port',
73+
CARDANO_WALLET_PORT
74+
);
7375
const isSelfnodeRunning =
7476
processList.length && processList[0].name === processName;
7577

@@ -216,7 +218,7 @@ const setupMockTokenMetadataServer = async (
216218
})();
217219

218220
// @ts-ignore ts-migrate(2322) FIXME: Type '{ pid: number; ppid?: number; uid?: number; ... Remove this comment to see the full error message
219-
const processList: Array<Process> = await find(
221+
const processList: Array<Process> = await wrappedFind(
220222
'port',
221223
TOKEN_METADATA_SERVER_PORT
222224
);

source/main/utils/processes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const getProcess = async (
7777
* Another solution would be to patch `find-process` to construct the `ps` invocation itself, not using `/bin/sh`
7878
* for that (i.e. `exec('ps', 'aux')` instead of `exec('ps aux')` which is really `exec('/bin/sh', '-c', 'ps aux')`.
7979
*/
80-
const wrappedFind = async (
80+
export const wrappedFind = async (
8181
type: 'name' | 'pid' | 'port',
8282
value: string | number | RegExp,
8383
strict?: boolean

0 commit comments

Comments
 (0)