mirror of
https://github.com/appium/appium.git
synced 2026-01-23 19:00:31 -06:00
Merge branch 'master' of github.com:DylanLacey/appium-1
This commit is contained in:
@@ -55,6 +55,6 @@ if (process.argv[2] === "shell") {
|
||||
else {
|
||||
var args = parser().parseArgs();
|
||||
args.verbose = 1;
|
||||
console.log("Pre-flight check ...".grey);
|
||||
appium.run(args, function() { console.log('Rock and roll.'.grey); });
|
||||
//console.log("Pre-flight check ...".grey);
|
||||
appium.run(args, function() { /* console.log('Rock and roll.'.grey); */ });
|
||||
}
|
||||
|
||||
@@ -6,27 +6,32 @@ var clientPath = 'instruments/client.js';
|
||||
var defWaitForDataTimeout = 60;
|
||||
var waitForDataTimeout = defWaitForDataTimeout;
|
||||
|
||||
var getNodeBinaryPath = function() {
|
||||
var res = system.performTaskWithPathArgumentsTimeout('/bin/bash', ['-c', 'which node'], 3);
|
||||
var getBinaryPath = function(cmd) {
|
||||
var res = system.performTaskWithPathArgumentsTimeout('/bin/bash', ['-c', 'which ' + cmd], 3);
|
||||
if (res.exitCode !== 0) {
|
||||
throw new Error("Failed trying to get node.js binary path");
|
||||
throw new Error("Failed trying to get binary path " + cmd);
|
||||
} else {
|
||||
var path = res.stdout.trim();
|
||||
if (path.length) {
|
||||
return path;
|
||||
} else {
|
||||
throw new Error("Could not find a node.js binary, please make sure you have one available!");
|
||||
throw new Error("Could not find a binary for " + cmd + ", please make sure you have one available!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var sendResultAndGetNext = function(result) {
|
||||
var args = [clientPath, '-s', '/tmp/instruments_sock'], res;
|
||||
var args = ['-s', '/tmp/instruments_sock'], res
|
||||
, binaryPath = globalPath;
|
||||
if (globalPath === null) {
|
||||
binaryPath = nodePath;
|
||||
args.unshift(clientPath);
|
||||
}
|
||||
if (typeof result !== "undefined") {
|
||||
args = args.concat(['-r', JSON.stringify(result)]);
|
||||
}
|
||||
try {
|
||||
res = system.performTaskWithPathArgumentsTimeout(nodePath, args, waitForDataTimeout);
|
||||
res = system.performTaskWithPathArgumentsTimeout(binaryPath, args, waitForDataTimeout);
|
||||
} catch(e) {
|
||||
console.log("Socket timed out waiting for a new command, why wasn't there one?");
|
||||
return null;
|
||||
@@ -43,4 +48,8 @@ var getFirstCommand = function() {
|
||||
return sendResultAndGetNext();
|
||||
};
|
||||
|
||||
var nodePath = getNodeBinaryPath();
|
||||
var globalPath = null;
|
||||
try {
|
||||
globalPath = getBinaryPath('instruments_client');
|
||||
} catch (e) { }
|
||||
var nodePath = getBinaryPath('node');
|
||||
|
||||
@@ -20,16 +20,18 @@ var connect = function(args) {
|
||||
});
|
||||
};
|
||||
|
||||
var parser = new ap({
|
||||
version: '0.0.1',
|
||||
});
|
||||
parser.addArgument(['-r', '--result'], {defaultValue: null, required: false});
|
||||
parser.addArgument(['-s', '--socket'], {defaultValue: '/tmp/instruments_sock', required: false});
|
||||
|
||||
if (module === require.main) {
|
||||
var parser = new ap({
|
||||
version: '0.0.1',
|
||||
});
|
||||
parser.addArgument(['-r', '--result'], {defaultValue: null, required: false});
|
||||
parser.addArgument(['-s', '--socket'], {defaultValue: '/tmp/instruments_sock', required: false});
|
||||
var args = parser.parseArgs();
|
||||
connect(args);
|
||||
}
|
||||
|
||||
module.exports.parser = parser;
|
||||
module.exports.connect = function(result, socket) {
|
||||
var args = {result: result, socket: socket};
|
||||
connect(args);
|
||||
|
||||
7
instruments/client_bin.js
Executable file
7
instruments/client_bin.js
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
|
||||
var client = require('./client.js');
|
||||
|
||||
var args = client.parser.parseArgs();
|
||||
client.connect(args.result, args.socket);
|
||||
@@ -5,7 +5,7 @@
|
||||
"automation",
|
||||
"javascript"
|
||||
],
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"author": "appium-discuss@googlegroups.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -19,7 +19,8 @@
|
||||
],
|
||||
"main": "./server.js",
|
||||
"bin": {
|
||||
"appium": "./app/bin.js"
|
||||
"appium": "./app/bin.js",
|
||||
"instruments_client": "./instruments/client_bin.js"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "./app"
|
||||
|
||||
Reference in New Issue
Block a user