Skip to content

Commit d5b1784

Browse files
committed
refactor: migrate readPackageUp function to @wdio/native-utils and update imports in launcher and pathResolver
1 parent 2ca3274 commit d5b1784

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

packages/electron-service/src/launcher.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ import {
1515

1616
const log = createLogger('wdio-electron-service', 'launcher');
1717

18-
async function readPackageUp(options: { cwd: string }): Promise<NormalizedReadResult | undefined> {
19-
const { readPackageUp: readPkg } = await import('read-package-up');
20-
return readPkg(options);
21-
}
22-
18+
import { readPackageUp } from '@wdio/native-utils';
2319
import type { Capabilities, Options, Services } from '@wdio/types';
2420
import getPort from 'get-port';
2521
import type { NormalizedReadResult } from 'read-package-up';

packages/electron-service/src/pathResolver.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import { access } from 'node:fs/promises';
22
import path from 'node:path';
3-
import { getAppBuildInfo, getBinaryPath, getElectronVersion } from '@wdio/native-utils';
3+
import { getAppBuildInfo, getBinaryPath, getElectronVersion, readPackageUp } from '@wdio/native-utils';
44
import type { NormalizedReadResult } from 'read-package-up';
55

6-
async function readPackageUp(options: { cwd: string }): Promise<NormalizedReadResult | undefined> {
7-
const { readPackageUp: readPkg } = await import('read-package-up');
8-
return readPkg(options);
9-
}
10-
116
/**
127
* Validate that a file path exists and is accessible
138
* @param filePath - The path to validate

packages/native-utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export {
1515
} from './diagnostics.js';
1616
export { getElectronVersion } from './electronVersion.js';
1717
export type { LogArea } from './log.js';
18+
export { readPackageUp } from './package.js';
1819
export {
1920
Err,
2021
isErr,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { NormalizedReadResult } from 'read-package-up';
2+
3+
export async function readPackageUp(options: { cwd: string }): Promise<NormalizedReadResult | undefined> {
4+
const { readPackageUp: readPkg } = await import('read-package-up');
5+
return readPkg(options);
6+
}

0 commit comments

Comments
 (0)