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: 10 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ export function normalizeVersion (version) {
export function getXcrunBinary () {
return process.env.XCRUN_BINARY || 'xcrun';
}

/**
* Generate a UUID v4
*
* @returns {Promise<string>}
*/
export async function uuidV4 () {
const uuidLib = await import('uuid');
return uuidLib.v4();
}
4 changes: 2 additions & 2 deletions lib/subcommands/io.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { rimraf } from 'rimraf';
import { v4 as uuidV4 } from 'uuid';
import path from 'path';
import os from 'os';
import fs from 'fs/promises';
import { uuidV4 } from '../helpers';

const commands = {};

Expand All @@ -19,7 +19,7 @@ const commands = {};
*/
commands.getScreenshot = async function getScreenshot () {
const udid = this.requireUdid('io screenshot');
const pathToScreenshotPng = path.resolve(os.tmpdir(), `${uuidV4()}.png`);
const pathToScreenshotPng = path.resolve(os.tmpdir(), `${await uuidV4()}.png`);
try {
await this.exec('io', {
args: [udid, 'screenshot', pathToScreenshotPng],
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/keychain.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os from 'os';
import fs from 'fs/promises';
import { v4 as uuidV4 } from 'uuid';
import { uuidV4 } from '../helpers';
import path from 'path';
import _ from 'lodash';
import { rimraf } from 'rimraf';
Expand All @@ -13,7 +13,7 @@ const commands = {};
* @param {(filePath: string) => Promise<any>} onPayloadStored
*/
async function handleRawPayload (payload, onPayloadStored) {
const filePath = path.resolve(os.tmpdir(), `${uuidV4()}.pem`);
const filePath = path.resolve(os.tmpdir(), `${await uuidV4()}.pem`);
try {
if (_.isBuffer(payload)) {
await fs.writeFile(filePath, payload);
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/push.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rimraf } from 'rimraf';
import { v4 as uuidV4 } from 'uuid';
import { uuidV4 } from '../helpers';
import path from 'path';
import os from 'os';
import fs from 'fs/promises';
Expand Down Expand Up @@ -28,7 +28,7 @@ const commands = {};
* @throws {Error} If the `udid` instance property is unset
*/
commands.pushNotification = async function pushNotification (payload) {
const dstPath = path.resolve(os.tmpdir(), `${uuidV4()}.json`);
const dstPath = path.resolve(os.tmpdir(), `${await uuidV4()}.json`);
try {
await fs.writeFile(dstPath, JSON.stringify(payload), 'utf8');
await this.exec('push', {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"semver": "^7.0.0",
"source-map-support": "^0.x",
"teen_process": "^3.0.0",
"uuid": "^11.0.1",
"uuid": "^13.0.0",
"which": "^5.0.0"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/simctl-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Simctl } from '../../lib/simctl.js';
import xcode from 'appium-xcode';
import { retryInterval } from 'asyncbox';
import { rimraf } from 'rimraf';
import { v4 as uuidV4 } from 'uuid';
import { uuidV4 } from '../../lib/helpers';
import path from 'path';
import os from 'os';
import fs from 'fs/promises';
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(), `${uuidV4()}.png`);
picturePath = path.join(os.tmpdir(), `${await uuidV4()}.png`);
await fs.writeFile(picturePath, Buffer.from(BASE64_PNG, 'base64').toString('binary'), 'binary');
});
after(async function () {
Expand Down