You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by al...@apache.org on 2016/06/01 14:21:07 UTC
cordova-paramedic git commit: CB-11351 Fixed JSHint warnings,
white space and license headers
Repository: cordova-paramedic
Updated Branches:
refs/heads/master d11156fbc -> d27099569
CB-11351 Fixed JSHint warnings, white space and license headers
Project: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/commit/d2709956
Tree: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/tree/d2709956
Diff: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/diff/d2709956
Branch: refs/heads/master
Commit: d27099569d1d46af930b36397444bffb7163d54e
Parents: d11156f
Author: Alexander Sorokin <al...@akvelon.com>
Authored: Wed Jun 1 16:52:49 2016 +0300
Committer: Alexander Sorokin <al...@akvelon.com>
Committed: Wed Jun 1 16:56:59 2016 +0300
----------------------------------------------------------------------
lib/LocalServer.js | 40 +++++++------
lib/ParamedicAppUninstall.js | 71 +++++++++++++++---------
lib/ParamedicConfig.js | 48 ++++++++--------
lib/ParamedicKill.js | 77 +++++++++++++++----------
lib/ParamedicLog.js | 74 ++++++++++++++----------
lib/ParamedicTargetChooser.js | 87 +++++++++++++++++------------
lib/ParamediciOSPermissions.js | 50 ++++++++++++-----
lib/PluginsManager.js | 14 ++---
lib/Reporters.js | 4 +-
lib/paramedic.js | 108 ++++++++++++++++++------------------
lib/utils/execWrapper.js | 7 +--
lib/utils/utilities.js | 78 ++++++++++++++++----------
12 files changed, 383 insertions(+), 275 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/LocalServer.js
----------------------------------------------------------------------
diff --git a/lib/LocalServer.js b/lib/LocalServer.js
index 0da48ac..c8e5422 100644
--- a/lib/LocalServer.js
+++ b/lib/LocalServer.js
@@ -17,21 +17,19 @@
under the License.
*/
-var Q = require('q'),
- io = require('socket.io'),
- logger = require('./utils').logger,
- exec = require('./utils').exec,
- path = require('path'),
- util = require('util'),
- portChecker = require('tcp-port-used'),
- EventEmitter = require('events').EventEmitter,
- localtunnel = require('localtunnel');
+var Q = require('q');
+var io = require('socket.io');
+var logger = require('./utils').logger;
+var util = require('util');
+var portChecker = require('tcp-port-used');
+var EventEmitter = require('events').EventEmitter;
+var localtunnel = require('localtunnel');
// how many ms without a pong packet to consider the connection closed
-var CONNECTION_HEARBEAT_PING_TIMEOUT = 60000,
+var CONNECTION_HEARBEAT_PING_TIMEOUT = 60000;
// how many ms before sending a new ping packet
- CONNECTION_HEARBEAT_PING_INTERVAL = 25000;
+var CONNECTION_HEARBEAT_PING_INTERVAL = 25000;
function LocalServer(port, externalServerUrl) {
this.port = port;
@@ -40,11 +38,11 @@ function LocalServer(port, externalServerUrl) {
util.inherits(LocalServer, EventEmitter);
-LocalServer.startServer = function(ports, externalServerUrl, useTunnel) {
+LocalServer.startServer = function (ports, externalServerUrl, useTunnel) {
logger.normal("local-server: scanning ports from " + ports.start + " to " + ports.end);
return LocalServer.getFirstAvailablePort(ports.start, ports.end)
- .then(function(port) {
+ .then(function (port) {
logger.normal("local-server: port " + port + " is available");
logger.info("local-server: starting local medic server");
@@ -59,7 +57,7 @@ LocalServer.startServer = function(ports, externalServerUrl, useTunnel) {
});
};
-LocalServer.getFirstAvailablePort = function(startPort, endPort) {
+LocalServer.getFirstAvailablePort = function (startPort, endPort) {
return portChecker.check(startPort).then(function (isInUse) {
if (!isInUse) {
return startPort;
@@ -71,13 +69,13 @@ LocalServer.getFirstAvailablePort = function(startPort, endPort) {
});
};
-LocalServer.prototype.createTunnel = function() {
+LocalServer.prototype.createTunnel = function () {
logger.info('cordova-paramedic: attempt to create local tunnel');
var self = this;
return Q.Promise(function(resolve, reject) {
- var tunnel = localtunnel(self.port, function(err, tunnel) {
+ var tunnel = localtunnel(self.port, function (err, tunnel) {
if (err) {
reject('Unable to create local tunnel: ' + err);
return;
@@ -90,13 +88,13 @@ LocalServer.prototype.createTunnel = function() {
});
// this trace is useful to debug test run timeout issue
- tunnel.on('close', function() {
+ tunnel.on('close', function () {
logger.normal('local-server: local tunnel has been closed');
});
});
};
-LocalServer.prototype.createSocketListener = function() {
+LocalServer.prototype.createSocketListener = function () {
var listener = io.listen(this.port, {
pingTimeout: CONNECTION_HEARBEAT_PING_TIMEOUT,
pingInterval: CONNECTION_HEARBEAT_PING_INTERVAL
@@ -108,7 +106,7 @@ LocalServer.prototype.createSocketListener = function() {
logger.info('local-server: new socket connection');
self.connection = socket;
- // server methods
+ // server methods
['deviceLog', 'disconnect', 'deviceInfo',
'jasmineStarted', 'specStarted', 'specDone',
'suiteStarted', 'suiteDone', 'jasmineDone'].forEach(function(route) {
@@ -120,7 +118,7 @@ LocalServer.prototype.createSocketListener = function() {
};
// Connection url could be platform specific so we pass platform as param here
-LocalServer.prototype.getConnectionUrl = function(platformId) {
+LocalServer.prototype.getConnectionUrl = function (platformId) {
// --useTunnel option
if (this.tunneledUrl) {
return this.tunneledUrl;
@@ -147,7 +145,7 @@ LocalServer.prototype.getConnectionUrl = function(platformId) {
return connectionUrl + ":" + this.port;
};
-LocalServer.prototype.isDeviceConnected = function() {
+LocalServer.prototype.isDeviceConnected = function () {
return !!this.connection;
};
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/ParamedicAppUninstall.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicAppUninstall.js b/lib/ParamedicAppUninstall.js
index 9473962..b997d5c 100644
--- a/lib/ParamedicAppUninstall.js
+++ b/lib/ParamedicAppUninstall.js
@@ -1,19 +1,38 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
var shelljs = require('shelljs');
var path = require('path');
-var fs = require("fs");
+var fs = require('fs');
var logger = require('./utils').logger;
var util = require('./utils').utilities;
function ParamedicAppUninstall(appPath, platform) {
- this.appPath = appPath;
+ this.appPath = appPath;
this.platform = platform;
}
-ParamedicAppUninstall.prototype.uninstallApp = function(targetObj, app) {
- if(!targetObj || !targetObj.target)
+ParamedicAppUninstall.prototype.uninstallApp = function (targetObj, app) {
+ if (!targetObj || !targetObj.target)
return;
- switch(this.platform) {
+ switch (this.platform) {
case util.ANDROID:
this.uninstallAppAndroid(targetObj, app);
break;
@@ -26,43 +45,43 @@ ParamedicAppUninstall.prototype.uninstallApp = function(targetObj, app) {
default:
break;
}
-}
+};
-ParamedicAppUninstall.prototype.uninstallAppAndroid = function(targetObj, app) {
- var uninstallCommand = "adb -s " + targetObj.target + " uninstall " + app;
+ParamedicAppUninstall.prototype.uninstallAppAndroid = function (targetObj, app) {
+ var uninstallCommand = 'adb -s ' + targetObj.target + ' uninstall ' + app;
this.executeUninstallCommand(uninstallCommand);
-}
+};
-ParamedicAppUninstall.prototype.uninstallAppWindows = function(targetObj, app) {
- var platformPath = path.join(this.appPath, "platforms", "windows");
- var packageJSPath = path.join(platformPath, "cordova", "lib", "package.js");
- var programFilesPath = process.env["ProgramFiles(x86)"] || process.env["ProgramFiles"];
- var appDeployPath = path.join(programFilesPath, "Microsoft SDKs",
- "Windows Phone", "v8.1", "Tools", "AppDeploy", "AppDeployCmd.exe");
+ParamedicAppUninstall.prototype.uninstallAppWindows = function (targetObj, app) {
+ var platformPath = path.join(this.appPath, 'platforms', 'windows');
+ var packageJSPath = path.join(platformPath, 'cordova', 'lib', 'package.js');
+ var programFilesPath = process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;
+ var appDeployPath = path.join(programFilesPath, 'Microsoft SDKs',
+ 'Windows Phone', 'v8.1', 'Tools', 'AppDeploy', 'AppDeployCmd.exe');
appDeployPath = '"' + appDeployPath + '"';
if (fs.existsSync(packageJSPath)) {
var packageJS = require(packageJSPath);
var appId = packageJS.getAppId(platformPath);
- var uninstallCommand = appDeployPath + " /uninstall " + appId + " /targetdevice:" + targetObj.target;
+ var uninstallCommand = appDeployPath + ' /uninstall ' + appId + ' /targetdevice:' + targetObj.target;
this.executeUninstallCommand(uninstallCommand);
}
return;
-}
+};
-ParamedicAppUninstall.prototype.uninstallAppIOS = function(targetObj, app) {
- var uninstallCommand = "xcrun simctl uninstall " + targetObj.simId + " uninstall " + app;
+ParamedicAppUninstall.prototype.uninstallAppIOS = function (targetObj, app) {
+ var uninstallCommand = 'xcrun simctl uninstall ' + targetObj.simId + ' uninstall ' + app;
this.executeUninstallCommand(uninstallCommand);
-}
+};
-ParamedicAppUninstall.prototype.executeUninstallCommand = function(uninstallCommand) {
- logger.info("cordova-paramedic: Running command: " + uninstallCommand);
- var uninstallResult = shelljs.exec(uninstallCommand, {silent: false, async: false});
+ParamedicAppUninstall.prototype.executeUninstallCommand = function (uninstallCommand) {
+ logger.info('cordova-paramedic: Running command: ' + uninstallCommand);
+ var uninstallResult = shelljs.exec(uninstallCommand, {silent: false, async: false});
if (uninstallResult.code > 0) {
- logger.error("Failed to uninstall the app" );
- logger.error("Error code: " + uninstallResult.code);
+ logger.error('Failed to uninstall the app');
+ logger.error('Error code: ' + uninstallResult.code);
}
return;
-}
+};
module.exports = ParamedicAppUninstall;
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/ParamedicConfig.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicConfig.js b/lib/ParamedicConfig.js
index b5d4b2f..9a7d44f 100644
--- a/lib/ParamedicConfig.js
+++ b/lib/ParamedicConfig.js
@@ -17,9 +17,9 @@
under the License.
*/
-var DEFAULT_START_PORT = 8008;
-var DEFAULT_END_PORT = 8018;
-var DEFAULT_TIMEOUT = 10 * 60 * 1000; // 10 minutes in msec - this will become a param
+var DEFAULT_START_PORT = 8008;
+var DEFAULT_END_PORT = 8018;
+var DEFAULT_TIMEOUT = 10 * 60 * 1000; // 10 minutes in msec - this will become a param
var util = require('./utils').utilities;
@@ -69,28 +69,28 @@ ParamedicConfig.prototype.shouldCleanUpAfterRun = function () {
return this._config.cleanUpAfterRun;
};
-ParamedicConfig.prototype.getPlatform = function() {
+ParamedicConfig.prototype.getPlatform = function () {
return this._config.platform;
};
-ParamedicConfig.prototype.setPlatform = function(platform) {
+ParamedicConfig.prototype.setPlatform = function (platform) {
this._config.platform = platform;
};
-ParamedicConfig.prototype.getAction = function() {
+ParamedicConfig.prototype.getAction = function () {
return this._config.action;
};
-ParamedicConfig.prototype.setAction = function(action) {
+ParamedicConfig.prototype.setAction = function (action) {
this._config.action = action;
};
-ParamedicConfig.prototype.getArgs = function() {
+ParamedicConfig.prototype.getArgs = function () {
return this._config.args;
};
-ParamedicConfig.prototype.getPlatformId = function() {
- return this._config.platform.split("@")[0];
+ParamedicConfig.prototype.getPlatformId = function () {
+ return this._config.platform.split('@')[0];
};
ParamedicConfig.prototype.getPlugins = function () {
@@ -101,62 +101,62 @@ ParamedicConfig.prototype.setPlugins = function (plugins) {
this._config.plugins = Array.isArray(plugins) ? plugins : [plugins];
};
-ParamedicConfig.prototype.getExternalServerUrl= function () {
+ParamedicConfig.prototype.getExternalServerUrl = function () {
return this._config.externalServerUrl;
};
-ParamedicConfig.prototype.isVerbose = function() {
+ParamedicConfig.prototype.isVerbose = function () {
return this._config.verbose;
};
-ParamedicConfig.prototype.isJustBuild = function() {
+ParamedicConfig.prototype.isJustBuild = function () {
return this._config.justbuild;
};
-ParamedicConfig.prototype.shouldUseSauce = function() {
+ParamedicConfig.prototype.shouldUseSauce = function () {
return this._config.shouldUseSauce;
};
-ParamedicConfig.prototype.getBuildName = function() {
+ParamedicConfig.prototype.getBuildName = function () {
return this._config.buildName;
};
-ParamedicConfig.prototype.getSauceUser = function() {
+ParamedicConfig.prototype.getSauceUser = function () {
return this._config.sauceUser;
};
-ParamedicConfig.prototype.getSauceKey = function() {
+ParamedicConfig.prototype.getSauceKey = function () {
return this._config.sauceKey;
};
-ParamedicConfig.prototype.isBrowserify = function() {
+ParamedicConfig.prototype.isBrowserify = function () {
return this._config.browserify;
};
-ParamedicConfig.prototype.getPorts = function() {
+ParamedicConfig.prototype.getPorts = function () {
return {
start: this._config.startPort || DEFAULT_START_PORT,
end: this._config.endPort || DEFAULT_END_PORT
};
};
-ParamedicConfig.prototype.getTimeout = function() {
+ParamedicConfig.prototype.getTimeout = function () {
return DEFAULT_TIMEOUT;
};
-ParamedicConfig.prototype.getLogMins = function() {
+ParamedicConfig.prototype.getLogMins = function () {
return this._config.logMins;
};
-ParamedicConfig.prototype.setLogMins = function(logMins) {
+ParamedicConfig.prototype.setLogMins = function (logMins) {
this._config.logMins = logMins;
};
-ParamedicConfig.prototype.setTccDb = function(tccDb) {
+ParamedicConfig.prototype.setTccDb = function (tccDb) {
this._config.tccDb = tccDb;
};
-ParamedicConfig.prototype.getTccDb = function() {
+ParamedicConfig.prototype.getTccDb = function () {
return this._config.tccDb;
};
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/ParamedicKill.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicKill.js b/lib/ParamedicKill.js
index e81b8bd..3adc631 100644
--- a/lib/ParamedicKill.js
+++ b/lib/ParamedicKill.js
@@ -1,16 +1,35 @@
#!/usr/bin/env node
-"use strict";
-
-var shelljs = require("shelljs");
-var util = require("./utils").utilities;
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+'use strict';
+
+var shelljs = require('shelljs');
+var util = require('./utils').utilities;
var logger = require('./utils').logger;
function ParamedicKill(platform) {
this.platform = platform;
}
-ParamedicKill.prototype.kill = function() {
+ParamedicKill.prototype.kill = function () {
// shell config
shelljs.config.fatal = false;
shelljs.config.silent = false;
@@ -19,7 +38,7 @@ ParamedicKill.prototype.kill = function() {
var platformTasks = this.tasksOnPlatform(this.platform);
if (platformTasks.length < 1) {
- console.warn("no known tasks to kill");
+ console.warn('no known tasks to kill');
return;
}
@@ -30,27 +49,27 @@ ParamedicKill.prototype.kill = function() {
this.killAdbServer();
}
-}
+};
ParamedicKill.prototype.tasksOnPlatform = function (platformName) {
var tasks = [];
switch (platformName) {
case util.WINDOWS:
- tasks = ["WWAHost.exe", "Xde.exe"];
+ tasks = ['WWAHost.exe', 'Xde.exe'];
break;
case util.IOS:
- tasks = ["Simulator", "iOS Simulator"];
+ tasks = ['Simulator', 'iOS Simulator'];
break;
case util.ANDROID:
if (util.isWindows()) {
- tasks = ["emulator-arm.exe"];
+ tasks = ['emulator-arm.exe'];
} else {
- tasks = ["emulator64-x86", "emulator64-arm"];
+ tasks = ['emulator64-x86', 'emulator64-arm'];
}
break;
}
return tasks;
-}
+};
ParamedicKill.prototype.killTasks = function (taskNames) {
if (!taskNames || taskNames.length < 1) {
@@ -59,42 +78,42 @@ ParamedicKill.prototype.killTasks = function (taskNames) {
var command = this.getKillCommand(taskNames);
- logger.info("running the following command:");
- logger.info(" " + command);
+ logger.info('running the following command:');
+ logger.info(' ' + command);
var killTasksResult = shelljs.exec(command, {silent: false, async: false });
if (killTasksResult.code !== 0) {
- console.warn("WARNING: kill command returned " + killTasksResult.code);
+ console.warn('WARNING: kill command returned ' + killTasksResult.code);
}
-}
+};
ParamedicKill.prototype.getKillCommand = function (taskNames) {
var cli;
var args;
if (util.isWindows()) {
- cli = "taskkill /F";
- args = taskNames.map(function (name) { return "/IM \"" + name + "\""; });
+ cli = 'taskkill /F';
+ args = taskNames.map(function (name) { return '/IM "' + name + '"'; });
} else {
- cli = "killall -9";
- args = taskNames.map(function (name) { return "\"" + name + "\""; });
+ cli = 'killall -9';
+ args = taskNames.map(function (name) { return '"' + name + '"'; });
}
- return cli + " " + args.join(" ");
-}
+ return cli + ' ' + args.join(' ');
+};
ParamedicKill.prototype.killAdbServer = function () {
- logger.info("Killing adb server");
- var killServerCommand = "adb kill-server";
+ logger.info('Killing adb server');
+ var killServerCommand = 'adb kill-server';
- logger.info("Running the following command:");
- logger.info(" " + killServerCommand);
+ logger.info('Running the following command:');
+ logger.info(' ' + killServerCommand);
var killServerResult = shelljs.exec(killServerCommand, {silent: false, async: false});
if (killServerResult.code !== 0) {
- logger.error("Failed killing adb server with code: " + killServerResult.code);
+ logger.error('Failed killing adb server with code: ' + killServerResult.code);
}
- logger.info("Finished killing adb server");
-}
+ logger.info('Finished killing adb server');
+};
module.exports = ParamedicKill;
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/ParamedicLog.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicLog.js b/lib/ParamedicLog.js
index 81e0bb3..14dea4b 100644
--- a/lib/ParamedicLog.js
+++ b/lib/ParamedicLog.js
@@ -1,17 +1,35 @@
#!/usr/bin/env node
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
/* jshint node: true */
-"use strict";
+'use strict';
-var shelljs = require("shelljs");
-var fs = require("fs");
-var path = require("path-extra");
+var shelljs = require('shelljs');
+var fs = require('fs');
+var path = require('path-extra');
var util = require('./utils').utilities;
var logger = require('./utils').logger;
-
-function ParamedicLog(platform, appPath, outputDir, targetObj){
+function ParamedicLog(platform, appPath, outputDir, targetObj) {
this.platform = platform;
this.appPath = appPath;
this.outputDir = outputDir;
@@ -23,60 +41,60 @@ ParamedicLog.prototype.logIOS = function (appPath) {
if (simId) {
// Now we can print out the log file
- var logPath = path.join(path.homedir(), "Library", "Logs", "CoreSimulator", simId, "system.log");
- var logCommand = "cat " + logPath;
+ var logPath = path.join(path.homedir(), 'Library', 'Logs', 'CoreSimulator', simId, 'system.log');
+ var logCommand = 'cat ' + logPath;
this.generateLogs(logCommand);
} else {
- logger.error("Failed to find ID of simulator");
+ logger.error('Failed to find ID of simulator');
}
-}
+};
ParamedicLog.prototype.logWindows = function (appPath, logMins) {
- var logScriptPath = path.join(appPath, "platforms", "windows", "cordova", "log.bat");
+ var logScriptPath = path.join(appPath, 'platforms', 'windows', 'cordova', 'log.bat');
if (fs.existsSync(logScriptPath)) {
var mins = util.DEFAULT_LOG_TIME;
if (logMins) {
mins = logMins + util.DEFAULT_LOG_TIME_ADDITIONAL;
}
- var logCommand = logScriptPath + " --dump --mins " + mins;
+ var logCommand = logScriptPath + ' --dump --mins ' + mins;
this.generateLogs(logCommand);
}
-}
+};
-ParamedicLog.prototype.logAndroid = function (){
- var logCommand = "adb -s " + this.targetObj.target + " logcat -d -v time";
+ParamedicLog.prototype.logAndroid = function () {
+ var logCommand = 'adb -s ' + this.targetObj.target + ' logcat -d -v time';
var numDevices = util.countAndroidDevices();
if (numDevices != 1) {
- logger.error("there must be exactly one emulator/device attached");
+ logger.error('there must be exactly one emulator/device attached');
return;
}
this.generateLogs(logCommand);
-}
+};
-ParamedicLog.prototype.generateLogs = function(logCommand) {
+ParamedicLog.prototype.generateLogs = function (logCommand) {
var logFile = this.getLogFileName();
logger.info('Running Command: ' + logCommand);
var result = shelljs.exec(logCommand, {silent: true, async: false});
if (result.code > 0) {
- logger.error("Failed to run command: " + logCommand);
- logger.error("Failure code: " + result.code);
+ logger.error('Failed to run command: ' + logCommand);
+ logger.error('Failure code: ' + result.code);
return;
}
try {
fs.writeFileSync(logFile, result.output);
} catch (ex) {
- logger.error("Cannot write the log results to the file. " + ex);
+ logger.error('Cannot write the log results to the file. ' + ex);
}
-}
+};
-ParamedicLog.prototype.getLogFileName = function() {
- return path.join(this.outputDir, this.platform + "_logs.txt");
-}
+ParamedicLog.prototype.getLogFileName = function () {
+ return path.join(this.outputDir, this.platform + '_logs.txt');
+};
-ParamedicLog.prototype.collectLogs = function (logMins){
+ParamedicLog.prototype.collectLogs = function (logMins) {
shelljs.config.fatal = false;
shelljs.config.silent = false;
@@ -91,9 +109,9 @@ ParamedicLog.prototype.collectLogs = function (logMins){
this.logWindows(this.appPath, logMins);
break;
default:
- logger.error("Logging is unsupported for " + platform);
+ logger.error('Logging is unsupported for ' + this.platform);
break;
}
-}
+};
module.exports = ParamedicLog;
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/ParamedicTargetChooser.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicTargetChooser.js b/lib/ParamedicTargetChooser.js
index 424f4c0..0d5ffcd 100644
--- a/lib/ParamedicTargetChooser.js
+++ b/lib/ParamedicTargetChooser.js
@@ -1,21 +1,39 @@
-var Q = require('q');
-var shelljs = require('shelljs');
-var path = require("path-extra");
-var logger = require('./utils').logger;
-var util = require('./utils').utilities;
-var spawn = require('child_process').spawn;
-var ParamedicKill = require('./ParamedicKill');
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var Q = require('q');
+var shelljs = require('shelljs');
+var path = require('path-extra');
+var logger = require('./utils').logger;
+var util = require('./utils').utilities;
+var ParamedicKill = require('./ParamedicKill');
var ANDROID_RETRY_TIMES = 3;
var ANDROID_TIME_OUT = 300000; //5 Minutes
function ParamedicTargetChooser(appPath, platform) {
- this.appPath = appPath;
+ this.appPath = appPath;
this.platform = platform;
}
-ParamedicTargetChooser.prototype.chooseTarget = function(emulator) {
- var targetObj = "";
+ParamedicTargetChooser.prototype.chooseTarget = function (emulator) {
+ var targetObj = '';
switch(this.platform) {
case util.ANDROID:
targetObj = this.chooseTargetForAndroid(emulator);
@@ -30,22 +48,21 @@ ParamedicTargetChooser.prototype.chooseTarget = function(emulator) {
break;
}
return targetObj;
-}
+};
-ParamedicTargetChooser.prototype.chooseTargetForAndroid = function(emulator) {
- logger.info("cordova-paramedic: Choosing Target for Android");
- var self = this;
- return this.startAnAndroidEmulator().then(function(emulatorId){
+ParamedicTargetChooser.prototype.chooseTargetForAndroid = function (emulator) {
+ logger.info('cordova-paramedic: Choosing Target for Android');
+ return this.startAnAndroidEmulator().then(function(emulatorId) {
var obj = {};
obj.target = emulatorId;
return obj;
});
-}
+};
-ParamedicTargetChooser.prototype.startAnAndroidEmulator = function() {
- logger.info("cordova-paramedic: Starting an Android emulator");
+ParamedicTargetChooser.prototype.startAnAndroidEmulator = function () {
+ logger.info('cordova-paramedic: Starting an Android emulator');
- var emuPath = path.join(this.appPath, "platforms", "android", "cordova", "lib", "emulator");
+ var emuPath = path.join(this.appPath, 'platforms', 'android', 'cordova', 'lib', 'emulator');
var emulator = require(emuPath);
var tryStart = function(numberTriesRemaining) {
@@ -58,7 +75,7 @@ ParamedicTargetChooser.prototype.startAnAndroidEmulator = function() {
paramedicKill.kill();
return tryStart(numberTriesRemaining - 1);
} else {
- logger.error("cordova-paramedic: Could not start an android emulator");
+ logger.error('cordova-paramedic: Could not start an android emulator');
return null;
}
});
@@ -73,22 +90,22 @@ ParamedicTargetChooser.prototype.startAnAndroidEmulator = function() {
return tryStart(ANDROID_RETRY_TIMES);
}
});
-}
+};
-ParamedicTargetChooser.prototype.chooseTargetForWindows = function(emulator) {
- logger.info("cordova-paramedic: Choosing Target for Windows");
- var windowsCommand = "cordova run --list --emulator";
+ParamedicTargetChooser.prototype.chooseTargetForWindows = function (emulator) {
+ logger.info('cordova-paramedic: Choosing Target for Windows');
+ var windowsCommand = 'cordova run --list --emulator';
- logger.info("cordova-paramedic: Running command: " + windowsCommand);
- var devicesResult = shelljs.exec(windowsCommand, {silent: true, async: false});
+ logger.info('cordova-paramedic: Running command: ' + windowsCommand);
+ var devicesResult = shelljs.exec(windowsCommand, {silent: true, async: false});
if (devicesResult.code > 0) {
- logger.error("Failed to get the list of devices for windows");
+ logger.error('Failed to get the list of devices for windows');
return Q({target: undefined});
}
var lines = devicesResult.output.split(/\n/);
if(lines.length <= 1) {
- logger.error("No devices/emulators available for windows");
+ logger.error('No devices/emulators available for windows');
return Q({target: undefined});
}
@@ -99,14 +116,14 @@ ParamedicTargetChooser.prototype.chooseTargetForWindows = function(emulator) {
return Q({target: targets[0].split('. ')[0].trim()});
};
-ParamedicTargetChooser.prototype.chooseTargetForIOS = function(emulator) {
- logger.info("cordova-paramedic: Choosing Target for iOS");
- var simulatorModelId = util.getSimulatorModelId();
- var split = simulatorModelId.split(", ");
- var device = split[0].trim();
+ParamedicTargetChooser.prototype.chooseTargetForIOS = function (emulator) {
+ logger.info('cordova-paramedic: Choosing Target for iOS');
+ var simulatorModelId = util.getSimulatorModelId();
+ var split = simulatorModelId.split(', ');
+ var device = split[0].trim();
+ var simId = util.getSimulatorId(simulatorModelId);
- var simId = util.getSimulatorId(simulatorModelId);
return Q({target: device, simId: simId});
-}
+};
module.exports = ParamedicTargetChooser;
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/ParamediciOSPermissions.js
----------------------------------------------------------------------
diff --git a/lib/ParamediciOSPermissions.js b/lib/ParamediciOSPermissions.js
index 1d19d1c..a6e5e3d 100644
--- a/lib/ParamediciOSPermissions.js
+++ b/lib/ParamediciOSPermissions.js
@@ -1,43 +1,63 @@
#!/usr/bin/env node
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
/* jshint node: true */
-var path = require('path');
-var fs = require('fs');
-var shelljs = require("shelljs");
-var logger = require('./utils').logger;
-var util = require('./utils').utilities;
+
+var path = require('path');
+var fs = require('fs');
+var shelljs = require('shelljs');
+var logger = require('./utils').logger;
+var util = require('./utils').utilities;
var TCC_FOLDER_PERMISSION = 0755;
function ParamediciOSPermissions(appName, tccDb, targetObj) {
- this.appName = appName;
- this.tccDb = tccDb;
+ this.appName = appName;
+ this.tccDb = tccDb;
this.targetObj = targetObj;
}
-ParamediciOSPermissions.prototype.updatePermissions = function(serviceList){
+ParamediciOSPermissions.prototype.updatePermissions = function (serviceList){
var simulatorsFolder = util.getSimulatorsFolder();
var simId = this.targetObj.simId;
logger.info('Sim Id is: ' + simId);
var destinationTCCFile = path.join(simulatorsFolder, simId, '/data/Library/TCC/TCC.db');
- if(!util.doesFileExist(destinationTCCFile)) {
+ if (!util.doesFileExist(destinationTCCFile)) {
// No TCC.db file exists by default. So, Copy the new TCC.db file
var destinationTCCFolder = path.join(simulatorsFolder, simId, '/data/Library/TCC');
- if(!util.doesFileExist(destinationTCCFolder)){
+ if(!util.doesFileExist(destinationTCCFolder)) {
fs.mkdir(destinationTCCFolder, TCC_FOLDER_PERMISSION);
}
- logger.info("Copying TCC Db file to " + destinationTCCFolder);
- shelljs.cp(this.tccDb, destinationTCCFolder)
+ logger.info('Copying TCC Db file to ' + destinationTCCFolder);
+ shelljs.cp(this.tccDb, destinationTCCFolder);
}
- for(var i = 0; i < serviceList.length; i++) {
+ for (var i = 0; i < serviceList.length; i++) {
var command = util.getSqlite3InsertionCommand(destinationTCCFile, serviceList[i], this.appName);
- logger.info("Running Command: " + command);
+ logger.info('Running Command: ' + command);
// If the service has an entry already, the insert command will fail.
// But, such a failure is intentionally not handled here.
shelljs.exec(command, {silent: true, async: false});
}
-}
+};
module.exports = ParamediciOSPermissions;
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/PluginsManager.js
----------------------------------------------------------------------
diff --git a/lib/PluginsManager.js b/lib/PluginsManager.js
index b7d6a17..755c67c 100644
--- a/lib/PluginsManager.js
+++ b/lib/PluginsManager.js
@@ -28,14 +28,14 @@ function PluginsManager(appRoot, storedCWD) {
this.storedCWD = storedCWD;
}
-PluginsManager.prototype.installPlugins = function(plugins) {
+PluginsManager.prototype.installPlugins = function (plugins) {
for(var n = 0; n < plugins.length; n++) {
var plugin = plugins[n];
this.installSinglePlugin(plugin);
}
};
-PluginsManager.prototype.installTestsForExistingPlugins = function() {
+PluginsManager.prototype.installTestsForExistingPlugins = function () {
var installedPlugins = new PluginInfoProvider().getAllWithinSearchPath(path.join(this.appRoot, 'plugins'));
var me = this;
installedPlugins.forEach(function(plugin) {
@@ -48,23 +48,23 @@ PluginsManager.prototype.installTestsForExistingPlugins = function() {
this.showPluginsVersions();
};
-PluginsManager.prototype.installSinglePlugin = function(plugin) {
+PluginsManager.prototype.installSinglePlugin = function (plugin) {
if (fs.existsSync(path.resolve(this.storedCWD, plugin))) {
plugin = path.resolve(this.storedCWD, plugin);
}
- logger.normal("cordova-paramedic: installing " + plugin);
+ logger.normal('cordova-paramedic: installing ' + plugin);
// var pluginPath = path.resolve(this.storedCWD, plugin);
var plugAddCmd = exec('cordova plugin add ' + plugin);
- if(plugAddCmd.code !== 0) {
+ if (plugAddCmd.code !== 0) {
logger.error('Failed to install plugin : ' + plugin);
throw new Error('Failed to install plugin : ' + plugin);
}
};
-PluginsManager.prototype.showPluginsVersions = function() {
- logger.verbose("cordova-paramedic: versions of installed plugins: ");
+PluginsManager.prototype.showPluginsVersions = function () {
+ logger.verbose('cordova-paramedic: versions of installed plugins: ');
exec('cordova plugins');
};
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/Reporters.js
----------------------------------------------------------------------
diff --git a/lib/Reporters.js b/lib/Reporters.js
index 2f6fcb8..e204c45 100644
--- a/lib/Reporters.js
+++ b/lib/Reporters.js
@@ -17,8 +17,8 @@
under the License.
*/
-var JasmineSpecReporter = require('jasmine-spec-reporter'),
- jasmineReporters = require('jasmine-reporters');
+var JasmineSpecReporter = require('jasmine-spec-reporter');
+var jasmineReporters = require('jasmine-reporters');
module.exports = function(outputDir) {
var reporters = [new JasmineSpecReporter({displayPendingSummary: false, displaySuiteNumber: true})];
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/paramedic.js
----------------------------------------------------------------------
diff --git a/lib/paramedic.js b/lib/paramedic.js
index 5af1964..1bbd696 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -31,10 +31,10 @@ var PluginsManager = require('./PluginsManager');
var getReporters = require('./Reporters');
var ParamedicKill = require('./ParamedicKill');
var ParamedicLog = require('./ParamedicLog');
+var wd = require('wd');
var ParamediciOSPermissions = require('./ParamediciOSPermissions');
var ParamedicTargetChooser = require('./ParamedicTargetChooser');
var ParamedicAppUninstall = require('./ParamedicAppUninstall');
-var wd = require('wd');
// Time to wait for initial device connection.
// If device has not connected within this interval the tests are stopped.
@@ -54,12 +54,12 @@ function ParamedicRunner(config, _callback) {
exec.setVerboseLevel(config.isVerbose());
}
-ParamedicRunner.prototype.run = function() {
+ParamedicRunner.prototype.run = function () {
var self = this;
this.checkSauceRequirements();
- return Q().then(function() {
+ return Q().then(function () {
self.createTempProject();
shell.pushd(self.tempFolder.name);
self.prepareProjectToRunTests();
@@ -88,22 +88,22 @@ ParamedicRunner.prototype.run = function() {
});
};
-ParamedicRunner.prototype.createTempProject = function() {
+ParamedicRunner.prototype.createTempProject = function () {
this.tempFolder = tmp.dirSync();
tmp.setGracefulCleanup();
- logger.info("cordova-paramedic: creating temp project at " + this.tempFolder.name);
+ logger.info('cordova-paramedic: creating temp project at ' + this.tempFolder.name);
exec('cordova create ' + this.tempFolder.name);
};
-ParamedicRunner.prototype.prepareProjectToRunTests = function() {
+ParamedicRunner.prototype.prepareProjectToRunTests = function () {
this.installPlugins();
this.setUpStartPage();
this.installPlatform();
this.checkPlatformRequirements();
};
-ParamedicRunner.prototype.installPlugins = function() {
- logger.info("cordova-paramedic: installing plugins");
+ParamedicRunner.prototype.installPlugins = function () {
+ logger.info('cordova-paramedic: installing plugins');
this.pluginsManager = new PluginsManager(this.tempFolder.name, this.storedCWD);
this.pluginsManager.installPlugins(this.config.getPlugins());
this.pluginsManager.installTestsForExistingPlugins();
@@ -112,28 +112,28 @@ ParamedicRunner.prototype.installPlugins = function() {
this.pluginsManager.installSinglePlugin(path.join(__dirname, '../paramedic-plugin'));
};
-ParamedicRunner.prototype.setUpStartPage = function() {
- logger.normal("cordova-paramedic: setting app start page to test page");
+ParamedicRunner.prototype.setUpStartPage = function () {
+ logger.normal('cordova-paramedic: setting app start page to test page');
shell.sed('-i', 'src="index.html"', 'src="cdvtests/index.html"', 'config.xml');
};
-ParamedicRunner.prototype.installPlatform = function() {
- logger.info("cordova-paramedic: adding platform : " + this.config.getPlatform());
+ParamedicRunner.prototype.installPlatform = function () {
+ logger.info('cordova-paramedic: adding platform : ' + this.config.getPlatform());
exec('cordova platform add ' + this.config.getPlatform());
};
-ParamedicRunner.prototype.checkPlatformRequirements = function() {
- logger.normal("cordova-paramedic: checking requirements for platform " + this.config.getPlatformId());
+ParamedicRunner.prototype.checkPlatformRequirements = function () {
+ logger.normal('cordova-paramedic: checking requirements for platform ' + this.config.getPlatformId());
var result = exec('cordova requirements ' + this.config.getPlatformId());
if (result.code !== 0)
throw new Error('Platform requirements check has failed!');
};
-ParamedicRunner.prototype.setPermissions = function() {
- if(this.config.getPlatformId() === 'ios'){
- logger.info("cordova-paramedic: Setting required permissions.");
- var tccDb = this.config.getTccDb();
+ParamedicRunner.prototype.setPermissions = function () {
+ if(this.config.getPlatformId() === 'ios') {
+ logger.info('cordova-paramedic: Setting required permissions.');
+ var tccDb = this.config.getTccDb();
if(tccDb) {
var appName = util.PARAMEDIC_DEFAULT_APP_NAME;
var paramediciOSPermissions = new ParamediciOSPermissions(appName, tccDb, this.targetObj);
@@ -142,7 +142,7 @@ ParamedicRunner.prototype.setPermissions = function() {
}
};
-ParamedicRunner.prototype.injectReporters = function() {
+ParamedicRunner.prototype.injectReporters = function () {
var self = this;
var reporters = getReporters(self.config.getOutputDir());
@@ -155,22 +155,22 @@ ParamedicRunner.prototype.injectReporters = function() {
});
};
-ParamedicRunner.prototype.subcribeForEvents = function() {
- this.server.on('deviceLog', function(data) {
+ParamedicRunner.prototype.subcribeForEvents = function () {
+ this.server.on('deviceLog', function (data) {
logger.verbose('device|console.' + data.type + ': ' + data.msg[0]);
});
- this.server.on('deviceInfo', function(data) {
+ this.server.on('deviceInfo', function (data) {
logger.normal('cordova-paramedic: Device info: ' + JSON.stringify(data));
});
};
ParamedicRunner.prototype.writeMedicConnectionUrl = function(url) {
- logger.normal("cordova-paramedic: writing medic log url to project " + url);
- fs.writeFileSync(path.join("www","medic.json"), JSON.stringify({logurl:url}));
+ logger.normal('cordova-paramedic: writing medic log url to project ' + url);
+ fs.writeFileSync(path.join('www','medic.json'), JSON.stringify({logurl:url}));
};
-ParamedicRunner.prototype.runTests = function() {
+ParamedicRunner.prototype.runTests = function () {
var self = this;
if (this.config.shouldUseSauce()) {
var command = this.getCommandForBuilding();
@@ -208,7 +208,7 @@ ParamedicRunner.prototype.runTests = function() {
}
};
-ParamedicRunner.prototype.waitForTests = function() {
+ParamedicRunner.prototype.waitForTests = function () {
var self = this;
logger.info('cordova-paramedic: waiting for test results');
return Q.promise(function(resolve, reject) {
@@ -221,7 +221,7 @@ ParamedicRunner.prototype.waitForTests = function() {
}
}, INITIAL_CONNECTION_TIMEOUT);
- self.server.on('jasmineDone', function(data) {
+ self.server.on('jasmineDone', function (data) {
logger.info('cordova-paramedic: tests have been completed');
var isTestPassed = (data.specResults.specFailed === 0);
@@ -229,21 +229,21 @@ ParamedicRunner.prototype.waitForTests = function() {
resolve(isTestPassed);
});
- self.server.on('disconnect', function() {
+ self.server.on('disconnect', function () {
reject(new Error('device is disconnected before passing the tests'));
});
});
};
-ParamedicRunner.prototype.getCommandForStartingTests = function() {
+ParamedicRunner.prototype.getCommandForStartingTests = function () {
var self = this;
- var cmd = "cordova " + this.config.getAction() + " " + this.config.getPlatformId();
+ var cmd = 'cordova ' + this.config.getAction() + ' ' + this.config.getPlatformId();
var paramedicTargetChooser = new ParamedicTargetChooser(this.tempFolder.name, this.config.getPlatformId());
- if(self.config.getAction() === 'build' || (self.config.getPlatformId() === "windows" && self.config.getArgs().indexOf('appx=8.1-phone') < 0)) {
+ if(self.config.getAction() === 'build' || (self.config.getPlatformId() === 'windows' && self.config.getArgs().indexOf('appx=8.1-phone') < 0)) {
//The app is to be run as a store app or just build. So no need to choose a target.
if (self.config.getArgs()) {
- cmd += " " + self.config.getArgs();
+ cmd += ' ' + self.config.getArgs();
}
return Q(cmd);
@@ -252,34 +252,34 @@ ParamedicRunner.prototype.getCommandForStartingTests = function() {
return paramedicTargetChooser.chooseTarget(true)
.then(function(targetObj){
self.targetObj = targetObj;
- cmd += " --target " + self.targetObj.target;
+ cmd += ' --target ' + self.targetObj.target;
if (self.config.getArgs()) {
- cmd += " " + self.config.getArgs();
+ cmd += ' ' + self.config.getArgs();
}
return cmd;
});
};
-ParamedicRunner.prototype.getCommandForBuilding = function() {
+ParamedicRunner.prototype.getCommandForBuilding = function () {
var cmd = 'cordova build ' + this.config.getPlatformId();
return cmd;
};
-ParamedicRunner.prototype.shouldWaitForTestResult = function() {
+ParamedicRunner.prototype.shouldWaitForTestResult = function () {
var action = this.config.getAction();
return action === 'run' || action === 'emulate';
};
-ParamedicRunner.prototype.waitForConnection = function() {
+ParamedicRunner.prototype.waitForConnection = function () {
var self = this;
var ERR_MSG = 'Seems like device not connected to local server in ' + INITIAL_CONNECTION_TIMEOUT / 1000 + ' secs';
return Q.promise(function(resolve, reject) {
- setTimeout(function() {
+ setTimeout(function () {
if (!self.server.isDeviceConnected()) {
reject(new Error(ERR_MSG));
} else {
@@ -289,7 +289,7 @@ ParamedicRunner.prototype.waitForConnection = function() {
});
};
-ParamedicRunner.prototype.cleanUpProject = function() {
+ParamedicRunner.prototype.cleanUpProject = function () {
if (this.config.shouldCleanUpAfterRun()) {
logger.info('cordova-paramedic: Deleting the application: ' + this.tempFolder.name);
shell.popd();
@@ -297,7 +297,7 @@ ParamedicRunner.prototype.cleanUpProject = function() {
}
};
-ParamedicRunner.prototype.checkSauceRequirements = function() {
+ParamedicRunner.prototype.checkSauceRequirements = function () {
if (this.config.shouldUseSauce()) {
if (this.config.getPlatformId() !== 'android' && this.config.getPlatformId() !== 'ios') {
throw new Error('Saucelabs only supports Android and iOS');
@@ -313,7 +313,7 @@ ParamedicRunner.prototype.checkSauceRequirements = function() {
}
};
-ParamedicRunner.prototype.packageApp = function() {
+ParamedicRunner.prototype.packageApp = function () {
var self = this;
switch (this.config.getPlatformId()) {
case 'ios': {
@@ -339,7 +339,7 @@ ParamedicRunner.prototype.packageApp = function() {
return Q.resolve();
};
-ParamedicRunner.prototype.uploadApp = function() {
+ParamedicRunner.prototype.uploadApp = function () {
logger.normal('cordova-paramedic: uploading ' + this.getAppName() + ' to Sauce Storage');
var sauceUser = this.config.getSauceUser();
@@ -355,34 +355,34 @@ ParamedicRunner.prototype.uploadApp = function() {
return execPromise(uploadCommand);
};
-ParamedicRunner.prototype.getPackagedPath = function() {
+ParamedicRunner.prototype.getPackagedPath = function () {
return path.join(this.getPackageFolder(), this.getPackageName());
};
-ParamedicRunner.prototype.killEmulatorProcess = function() {
+ParamedicRunner.prototype.killEmulatorProcess = function () {
if(this.config.shouldCleanUpAfterRun()){
- logger.info("cordova-paramedic: Killing the emulator process.");
+ logger.info('cordova-paramedic: Killing the emulator process.');
var paramedicKill = new ParamedicKill(this.config.getPlatformId());
paramedicKill.kill();
}
};
-ParamedicRunner.prototype.collectDeviceLogs = function() {
- logger.info("Collecting logs for the devices.");
+ParamedicRunner.prototype.collectDeviceLogs = function () {
+ logger.info('Collecting logs for the devices.');
var outputDir = this.config.getOutputDir()? this.config.getOutputDir(): this.tempFolder.name;
var logMins = this.config.getLogMins()? this.config.getLogMins(): util.DEFAULT_LOG_TIME;
var paramedicLog = new ParamedicLog(this.config.getPlatformId(), this.tempFolder.name, outputDir, this.targetObj);
paramedicLog.collectLogs(logMins);
};
-ParamedicRunner.prototype.uninstallApp = function() {
- logger.info("Uninstalling the app.");
+ParamedicRunner.prototype.uninstallApp = function () {
+ logger.info('Uninstalling the app.');
var paramedicAppUninstall = new ParamedicAppUninstall(this.tempFolder.name, this.config.getPlatformId());
paramedicAppUninstall.uninstallApp(this.targetObj,util.PARAMEDIC_DEFAULT_APP_NAME);
};
-ParamedicRunner.prototype.getPackageFolder = function() {
+ParamedicRunner.prototype.getPackageFolder = function () {
var packageFolder;
switch (this.config.getPlatformId()) {
case 'android':
@@ -412,7 +412,7 @@ ParamedicRunner.prototype.getPackageName = function () {
return packageName;
};
-ParamedicRunner.prototype.getBinaryPath = function() {
+ParamedicRunner.prototype.getBinaryPath = function () {
var binaryPath;
switch (this.config.getPlatformId()) {
case 'android':
@@ -427,7 +427,7 @@ ParamedicRunner.prototype.getBinaryPath = function() {
return binaryPath;
};
-ParamedicRunner.prototype.getBinaryName = function() {
+ParamedicRunner.prototype.getBinaryName = function () {
var binaryName;
switch (this.config.getPlatformId()) {
case 'android':
@@ -442,7 +442,7 @@ ParamedicRunner.prototype.getBinaryName = function() {
return binaryName;
};
-ParamedicRunner.prototype.getAppName = function() {
+ParamedicRunner.prototype.getAppName = function () {
var appName;
switch (this.config.getPlatformId()) {
case 'android':
@@ -457,7 +457,7 @@ ParamedicRunner.prototype.getAppName = function() {
return appName;
};
-ParamedicRunner.prototype.runSauceTests = function() {
+ParamedicRunner.prototype.runSauceTests = function () {
logger.info('cordova-paramedic: running sauce tests');
var self = this;
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/utils/execWrapper.js
----------------------------------------------------------------------
diff --git a/lib/utils/execWrapper.js b/lib/utils/execWrapper.js
index aeb4689..44ad93b 100644
--- a/lib/utils/execWrapper.js
+++ b/lib/utils/execWrapper.js
@@ -33,10 +33,9 @@ function exec(cmd, onFinish, onData) {
}
}
-
function execPromise(cmd) {
- return Q.promise(function(resolve, reject) {
- exec(cmd, function(code, output) {
+ return Q.promise(function (resolve, reject) {
+ exec(cmd, function (code, output) {
if (code) {
reject(code, output);
} else {
@@ -46,7 +45,7 @@ function execPromise(cmd) {
});
}
-exec.setVerboseLevel = function(_verbose) {
+exec.setVerboseLevel = function (_verbose) {
verbose = _verbose;
};
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d2709956/lib/utils/utilities.js
----------------------------------------------------------------------
diff --git a/lib/utils/utilities.js b/lib/utils/utilities.js
index a3954a7..17ffcc6 100644
--- a/lib/utils/utilities.js
+++ b/lib/utils/utilities.js
@@ -1,25 +1,43 @@
#!/usr/bin/env node
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
var shelljs = require('shelljs');
-var verbose = undefined;
var fs = require('fs');
-var os = require("os");
+var os = require('os');
var util = require('util');
-var path = require("path-extra");
+var path = require('path-extra');
var logger = require('cordova-common').CordovaLogger.get();
var HEADING_LINE_PATTERN = /List of devices/m;
var DEVICE_ROW_PATTERN = /(emulator|device|host)/m;
-function isWindows () {
+function isWindows() {
return /^win/.test(os.platform());
}
function countAndroidDevices() {
- var listCommand = "adb devices";
+ var listCommand = 'adb devices';
- logger.info("running:");
- logger.info(" " + listCommand);
+ logger.info('running:');
+ logger.info(' ' + listCommand);
var numDevices = 0;
var result = shelljs.exec(listCommand, {silent: false, async: false});
@@ -31,25 +49,25 @@ function countAndroidDevices() {
return numDevices;
}
-function secToMin (seconds) {
+function secToMin(seconds) {
return Math.ceil(seconds / 60);
}
function getSimulatorsFolder() {
- var simulatorsFolderPath = path.join(path.homedir(), "Library", "Developer", "CoreSimulator", "Devices");
+ var simulatorsFolderPath = path.join(path.homedir(), 'Library', 'Developer', 'CoreSimulator', 'Devices');
return simulatorsFolderPath;
}
function getSimulatorModelId() {
- var findSimCommand = "cordova run --list --emulator | grep ^iPhone | tail -n1";
+ var findSimCommand = 'cordova run --list --emulator | grep ^iPhone | tail -n1';
- logger.info("running:");
- logger.info(" " + findSimCommand);
+ logger.info('running:');
+ logger.info(' ' + findSimCommand);
var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: false});
if (findSimResult.code > 0) {
- logger.error("Failed to find simulator we deployed to");
+ logger.error('Failed to find simulator we deployed to');
return;
}
@@ -57,22 +75,22 @@ function getSimulatorModelId() {
}
function getSimulatorId(findSimResult) {
- var split = findSimResult.split(", ");
+ var split = findSimResult.split(', ');
// Format of the output is "iPhone-6s-Plus, 9.1"
// Extract the device name and the version number
- var device = split[0].replace(/-/g, " ").trim();
+ var device = split[0].replace(/-/g, ' ').trim();
var version = split[1].trim();
// Next, figure out the ID of the simulator we found
- var instrCommand = "instruments -s devices | grep ^iPhone";
- logger.info("running:");
- logger.info(" " + instrCommand);
+ var instrCommand = 'instruments -s devices | grep ^iPhone';
+ logger.info('running:');
+ logger.info(' ' + instrCommand);
var instrResult = shelljs.exec(instrCommand, {silent: true, async: false});
if (instrResult.code > 0) {
- logger.error("Failed to get the list of simulators");
+ logger.error('Failed to get the list of simulators');
return;
}
@@ -81,7 +99,7 @@ function getSimulatorId(findSimResult) {
var simId = null;
var lines = instrResult.output.split(/\n/);
- lines.forEach(function(line) {
+ lines.forEach(function (line) {
var simIdMatch = simIdRegex.exec(line);
if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === device && simIdMatch[2] === version) {
simId = encodeURIComponent(simIdMatch[3]);
@@ -94,7 +112,7 @@ function getSimulatorId(findSimResult) {
function doesFileExist(filePath) {
var fileExists = false;
try {
- stats = fs.statSync(filePath);
+ fs.statSync(filePath);
fileExists = true;
} catch (e) {
fileExists = false;
@@ -103,18 +121,18 @@ function doesFileExist(filePath) {
}
function getSqlite3InsertionCommand(destinationTCCFile, service, appName) {
- return util.format( 'sqlite3 %s "insert into access'
- + '(service, client, client_type, allowed, prompt_count, csreq) values(\'%s\', \'%s\', '
- + '0,1,1,NULL)"', destinationTCCFile, service, appName);
+ return util.format('sqlite3 %s "insert into access' +
+ '(service, client, client_type, allowed, prompt_count, csreq) values(\'%s\', \'%s\', ' +
+ '0,1,1,NULL)"', destinationTCCFile, service, appName);
}
module.exports = {
- ANDROID: "android",
- IOS: "ios",
- WINDOWS: "windows",
- PARAMEDIC_DEFAULT_APP_NAME: "io.cordova.hellocordova",
- SAUCE_USER_ENV_VAR: "SAUCE_USER",
- SAUCE_KEY_ENV_VAR: "SAUCE_ACCESS_KEY",
+ ANDROID: 'android',
+ IOS: 'ios',
+ WINDOWS: 'windows',
+ PARAMEDIC_DEFAULT_APP_NAME: 'io.cordova.hellocordova',
+ SAUCE_USER_ENV_VAR: 'SAUCE_USER',
+ SAUCE_KEY_ENV_VAR: 'SAUCE_ACCESS_KEY',
DEFAULT_LOG_TIME: 15,
DEFAULT_LOG_TIME_ADDITIONAL: 2,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org