Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ export function getXcrunBinary(): string {
return process.env.XCRUN_BINARY || 'xcrun';
}

/**
* Generate a UUID v4
*
* @returns Promise resolving to UUID string
*/
export async function uuidV4(): Promise<string> {
const uuidLib = await import('uuid');
return uuidLib.v4();
}

/**
* Convert plist-style output to JSON using plutil
*
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/io.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {rimraf} from 'rimraf';
import {randomUUID} from 'node:crypto';
import path from 'node:path';
import os from 'node:os';
import fs from 'node:fs/promises';
import {uuidV4} from '../helpers';
import type {Simctl} from '../simctl';

/**
Expand All @@ -17,7 +17,7 @@ import type {Simctl} from '../simctl';
*/
export async function getScreenshot(this: Simctl): Promise<string> {
const udid = this.requireUdid('io screenshot');
const pathToScreenshotPng = path.resolve(os.tmpdir(), `${await uuidV4()}.png`);
const pathToScreenshotPng = path.resolve(os.tmpdir(), `${randomUUID()}.png`);
try {
await this.exec('io', {
args: [udid, 'screenshot', pathToScreenshotPng],
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/push.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {rimraf} from 'rimraf';
import {uuidV4} from '../helpers';
import {randomUUID} from 'node:crypto';
import path from 'node:path';
import os from 'node:os';
import fs from 'node:fs/promises';
Expand All @@ -26,7 +26,7 @@ import type {Simctl} from '../simctl';
* @throws {Error} If the `udid` instance property is unset
*/
export async function pushNotification(this: Simctl, payload: Record<string, any>): Promise<void> {
const dstPath = path.resolve(os.tmpdir(), `${await uuidV4()}.json`);
const dstPath = path.resolve(os.tmpdir(), `${randomUUID()}.json`);
try {
await fs.writeFile(dstPath, JSON.stringify(payload), 'utf8');
await this.exec('push', {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/simctl-e2e-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Simctl} from '../../lib/simctl';
import xcode from 'appium-xcode';
import {retryInterval} from 'asyncbox';
import {rimraf} from 'rimraf';
import {uuidV4} from '../../lib/helpers';
import {randomUUID} from 'node:crypto';
import path from 'node:path';
import os from 'node:os';
import fs from 'node:fs/promises';
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('simctl', function () {
it('should delete devices', async function () {
await simctl.deleteDevice();
const sdkDevices = await simctl.getDevices(sdk);
expect(sdkDevices.map((item) => item.name)).to.not.include(simctl.udid);
expect(sdkDevices.map((item) => item.udid)).to.not.include(simctl.udid);

// so we do not delete again
simctl.udid = null;
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('simctl', function () {
if (major < 8 || (major === 8 && minor < 1)) {
return this.skip();
}
picturePath = path.join(os.tmpdir(), `${await uuidV4()}.png`);
picturePath = path.join(os.tmpdir(), `${randomUUID()}.png`);
await fs.writeFile(
picturePath,
Buffer.from(BASE64_PNG, 'base64').toString('binary'),
Expand Down
Loading