Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
build
*.log
.idea
coverage
21 changes: 8 additions & 13 deletions lib/xcode.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { getLogger } from 'appium-logger';
import { util, fs } from 'appium-support';
import { util, fs, plist } from 'appium-support';
import path from 'path';
import { retry } from 'asyncbox';
import _ from 'lodash';
import plist from 'plist';
import { parse as parsePlistData } from 'plist';
import { exec } from 'teen_process';
import bplistParser from 'bplist-parser';
import B from 'bluebird';

let parseFile = B.promisify(bplistParser.parseFile);

const env = process.env;

Expand Down Expand Up @@ -111,8 +107,8 @@ async function getVersionWithoutRetry () {
throw new Error(`Could not get Xcode version. ${plistPath} does not exist on disk.`);
}

let version = await parseFile(plistPath);
version = version[0].CFBundleShortVersionString;
let version = await plist.parsePlistFile(plistPath);
version = version.CFBundleShortVersionString;

let versionPattern = /\d\.\d\.*\d*/;
// need to use string#match here; previous code used regexp#exec, which does not return null
Expand All @@ -124,14 +120,14 @@ async function getVersionWithoutRetry () {
return match[0];
}

const getVersionMemorized = _.memoize(
const getVersionMemoized = _.memoize(
function (retries = DEFAULT_NUMBER_OF_RETRIES) {
return retry(retries, getVersionWithoutRetry);
}
);

async function getVersion (parse = false, retries = DEFAULT_NUMBER_OF_RETRIES) {
let version = await getVersionMemorized(retries);
let version = await getVersionMemoized(retries);
if (!parse) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you've imported parse this local variable will clash now.

return version;
}
Expand Down Expand Up @@ -186,7 +182,6 @@ const getAutomationTraceTemplatePath = _.memoize(
async function getMaxIOSSDKWithoutRetry () {

const version = await getVersion();

if (version[0] === '4') {
return '6.1';
}
Expand Down Expand Up @@ -216,7 +211,7 @@ async function getConnectedDevices () {
const cmd = '/usr/sbin/system_profiler';
const args = ['-xml', 'SPUSBDataType'];
let {stdout} = await exec(cmd, args, {timeout: XCODE_SELECT_TIMEOUT});
let plistContent = plist.parse(stdout);
let plistContent = parsePlistData(stdout);

let devicesFound = [];
let entriesToSearch = [plistContent[0]];
Expand Down Expand Up @@ -270,7 +265,7 @@ const getInstrumentsPath = _.memoize(
function clearInternalCache () {

// memoized functions
const memoized = [getPath, getVersion, getAutomationTraceTemplatePath,
const memoized = [getPath, getVersionMemoized, getAutomationTraceTemplatePath,
getMaxIOSSDK, getInstrumentsPath];

memoized.forEach((f) => {
Expand Down
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ios",
"xcode"
],
"version": "2.0.8",
"version": "2.1.0-beta2",
"author": "appium",
"license": "Apache-2.0",
"repository": {
Expand All @@ -19,22 +19,21 @@
"engines": [
"node"
],
"main": "./build/lib/xcode.js",
"main": "./build/index.js",
"bin": {},
"directories": {
"lib": "lib"
},
"dependencies": {
"appium-logger": "^1.1.7",
"appium-support": "2.0.0-beta18",
"asyncbox": "^2.0.2",
"babel-runtime": "5.5.5",
"bluebird": "^2.9.34",
"bplist-parser": "^0.1.0",
"lodash": "^3.6.0",
"appium-support": "^2.0.0",
"asyncbox": "^2.3.0",
"babel-runtime": "=5.8.24",
"denodeify": "^1.2.1",
"lodash": "^3.10.0",
"plist": "^1.1.0",
"source-map-support": "^0.2.10",
"teen_process": "^1.1.0"
"source-map-support": "^0.3.2",
"teen_process": "^1.3.0"
},
"scripts": {
"prepublish": "gulp prepublish",
Expand All @@ -43,10 +42,9 @@
},
"devDependencies": {
"appium-gulp-plugins": "^1.3.0",
"chai": "^2.2.0",
"chai-as-promised": "^4.3.0",
"gulp": "^3.8.11",
"mochawait": "^2.0.0",
"chai": "^3.2.0",
"chai-as-promised": "^5.1.0",
"gulp": "^3.8.10",
"sinon": "^1.15.4"
}
}
12 changes: 12 additions & 0 deletions test/index-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// transpile:mocha

import xcode from '../index.js';
import chai from 'chai';

chai.should();

describe('index', () => {
it('exported objects should exist', () => {
xcode.should.exist;
});
});
3 changes: 1 addition & 2 deletions test/xcode-specs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// transpile:mocha

import xcode from '..';
import xcode from '../index';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import 'mochawait';
import { fs } from 'appium-support';
import _ from 'lodash';

Expand Down