appium-uiauto
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "appium-uiauto", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "appium uiauto ios driver", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -91,4 +91,56 @@ var system = UIATarget.localTarget().host(); | ||
var getNodePathFromAppiumApp = function () { | ||
var appScript = [ | ||
'try', | ||
' set appiumIsRunning to false', | ||
' tell application "System Events"', | ||
' set appiumIsRunning to name of every process contains "Appium"', | ||
' end tell', | ||
' if appiumIsRunning then', | ||
' tell application "Appium" to return node path', | ||
' end if', | ||
'end try', | ||
'return "NULL"' | ||
].join("\n"); | ||
var path = null; | ||
try { | ||
path = sysExec("osascript -e '" + appScript + "'"); | ||
if (path === "NULL") path = null; | ||
} catch (e) {} | ||
if (path) console.log("Found node in Appium.app"); | ||
return path; | ||
}; | ||
var guessNodePath = function () { | ||
var path = null; | ||
// let's try and find it... | ||
try { | ||
path = sysExec("echo $NODE_BIN"); | ||
console.log("Found node using $NODE_BIN: " + path); | ||
} catch (e) { | ||
try { | ||
path = sysExec('which node'); | ||
console.log("Found node using `which node`: " + path); | ||
} catch (e) { | ||
try { | ||
path = sysExec("ls /usr/local/bin/node"); | ||
console.log("Found node at " + path); | ||
} catch (e) { | ||
try { | ||
path = sysExec("ls /opt/local/bin/node"); | ||
console.log("Found node at " + path); | ||
} catch (e) { | ||
throw new Error("Could not find node using `which node`, at /usr/" + | ||
"local/bin/node, at /opt/local/bin/node, at " + | ||
"$NODE_BIN, or by querying Appium.app. Where is " + | ||
"it?"); | ||
} | ||
} | ||
} | ||
} | ||
return path; | ||
}; | ||
// figure out where instruments client is (relative to where appium is run) | ||
var clientPath = (function() { | ||
var getClientPath = function () { | ||
var possiblePaths = [ | ||
@@ -98,16 +150,38 @@ './node_modules/.bin/instruments-client.js', | ||
]; | ||
for(var i=0; i<possiblePaths.length; i++){ | ||
if(fileExists(possiblePaths[i])) { | ||
for (var i = 0; i < possiblePaths.length; i++) { | ||
if (fileExists(possiblePaths[i])) { | ||
return possiblePaths[i]; | ||
} | ||
} | ||
})(); | ||
}; | ||
var clientPath = getClientPath(); | ||
console.log('Using instrument client with path: ' + clientPath); | ||
var sendResultAndGetNext = function (result) { | ||
curAppiumCmdId++; | ||
var args = ['-s', '/tmp/instruments_sock'], res | ||
, binaryPath = clientPath; | ||
, binaryPath; | ||
if ((typeof settings !== "undefined") && ('NODE_BIN' in settings)) { | ||
console.log("Using settings override for NODE_BIN: " + settings.NODE_BIN); | ||
binaryPath = settings.NODE_BIN; | ||
args.unshift(clientPath); | ||
} else { | ||
try { | ||
sysExec('/usr/bin/env node -v'); | ||
binaryPath = clientPath; | ||
} catch (err) { | ||
var binaryPath = getNodePathFromAppiumApp(); | ||
if (!binaryPath) { | ||
console.log( | ||
'It looks like node is not correctly setup please make sure ' + | ||
'the shebang\'/usr/bin/env node\' works or set NODE_BIN in settings.'); | ||
console.log('Guessing node path.'); | ||
binaryPath = guessNodePath(); | ||
} | ||
args.unshift(clientPath); | ||
} | ||
} | ||
if (typeof result !== "undefined") { | ||
@@ -122,5 +196,8 @@ args = args.concat(['-r', JSON.stringify(result)]); | ||
} | ||
var cmd = binaryPath + " " + args.join(" "); | ||
if (!res) { | ||
console.log("Instruments client (" + cmd + ") exited with null res"); | ||
return null; | ||
} | ||
if (res.exitCode !== 0) { | ||
var cmd = binaryPath + " " + args.join(" "); | ||
console.log("Instruments client (" + cmd + ") exited with " + res.exitCode + | ||
@@ -127,0 +204,0 @@ ", here's stderr:"); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74688
2304