Skip to content

Commit

Permalink
Fix exec usage (#83)
Browse files Browse the repository at this point in the history
* fix exec usage

* improve log message

* fix and improve command output
  • Loading branch information
janpio authored Dec 4, 2018
1 parent 80ecd5b commit 9146804
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/ParamedicAppUninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ParamedicAppUninstall.prototype.executeUninstallCommand = function (uninstallCom
logger.error('Error code: ' + code);
reject();
}
}, {silent: false, async: true});
});
}).timeout(60000)
.fail(function () {
logger.warn('cordova-paramedic: App uninstall timed out!');
Expand Down
4 changes: 2 additions & 2 deletions lib/ParamedicKill.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ParamedicKill.prototype.killTasks = function (taskNames) {
logger.info('running the following command:');
logger.info(' ' + command);

var killTasksResult = exec(command, {silent: false, async: false });
var killTasksResult = exec(command);
if (killTasksResult.code !== 0) {
console.warn('WARNING: kill command returned ' + killTasksResult.code);
}
Expand Down Expand Up @@ -116,7 +116,7 @@ ParamedicKill.prototype.killAdbServer = function () {
logger.info('Running the following command:');
logger.info(' ' + killServerCommand);

var killServerResult = exec(killServerCommand, {silent: false, async: false});
var killServerResult = exec(killServerCommand);
if (killServerResult.code !== 0) {
logger.error('Failed killing adb server with code: ' + killServerResult.code);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ParamedicLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ParamedicLog.prototype.generateLogs = function (logCommand) {
var logFile = this.getLogFileName();
logger.info('Running Command: ' + logCommand);

var result = exec(logCommand, {silent: true, async: false});
var result = exec(logCommand);
if (result.code > 0) {
logger.error('Failed to run command: ' + logCommand);
logger.error('Failure code: ' + result.code);
Expand Down
2 changes: 1 addition & 1 deletion lib/ParamedicTargetChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ParamedicTargetChooser.prototype.chooseTargetForWindows = function (emulator, ta
var windowsCommand = this.cli + ' run --list --emulator' + util.PARAMEDIC_COMMON_CLI_ARGS;

logger.info('cordova-paramedic: Running command: ' + windowsCommand);
var devicesResult = exec(windowsCommand, {silent: true, async: false});
var devicesResult = exec(windowsCommand);
if (devicesResult.code > 0) {
logger.error('Failed to get the list of devices for windows');
return Q({target: undefined});
Expand Down
2 changes: 1 addition & 1 deletion lib/PluginsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PluginsManager.prototype.installSinglePlugin = function (plugin) {
}

plugin += util.PARAMEDIC_COMMON_CLI_ARGS + util.PARAMEDIC_PLUGIN_ADD_ARGS;
logger.normal('cordova-paramedic: installing ' + plugin);
logger.normal('cordova-paramedic: installing plugin ' + plugin);

var plugAddCmd = exec(this.config.getCli() + ' plugin add ' + plugin);
if (plugAddCmd.code !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/paramedic.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ ParamedicRunner.prototype.packageApp = function () {
shell.pushd(self.getPackageFolder());
shell.rm('-rf', self.getPackageName());
console.log('Running command: ' + zipCommand + ' in dir: ' + shell.pwd());
exec(zipCommand, { silent: !self.config.isVerbose() }, function (code, stdout, stderr) {
exec(zipCommand, function (code, stdout, stderr) {
shell.popd();
if (code) {
reject('zip command returned with error code ' + code);
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function countAndroidDevices() {
logger.info(' ' + listCommand);

var numDevices = 0;
var result = exec(listCommand, {silent: false, async: false});
var result = exec(listCommand);
result.output.split('\n').forEach(function (line) {
if (!HEADING_LINE_PATTERN.test(line) && DEVICE_ROW_PATTERN.test(line)) {
numDevices += 1;
Expand Down Expand Up @@ -72,7 +72,7 @@ function getSimulatorModelId(cli, target) {
logger.info('running:');
logger.info(' ' + findSimCommand);

var findSimResult = exec(findSimCommand, {silent: true, async: false});
var findSimResult = exec(findSimCommand);

if (findSimResult.code > 0) {
logger.error('Failed to find simulator we deployed to');
Expand All @@ -95,7 +95,7 @@ function getSimulatorId(findSimResult) {
logger.info('running:');
logger.info(' ' + instrCommand);

var instrResult = exec(instrCommand, {silent: true, async: false});
var instrResult = exec(instrCommand);

if (instrResult.code > 0) {
logger.error('Failed to get the list of simulators');
Expand Down
17 changes: 10 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ var ParamedicConfig = require('./lib/ParamedicConfig');
var util = require('./lib/utils').utilities;

var USAGE = "Error missing args. \n" +
"cordova-paramedic --platform PLATFORM --plugin PATH [--justbuild --timeout MSECS --startport PORTNUM --endport PORTNUM --browserify --version]\n" +
"`PLATFORM` : the platform id. Currently supports 'ios', 'browser', 'windows', 'android'.\n" +
"\n" +
"cordova-paramedic --platform PLATFORM --plugin PATH [--justbuild --timeout MSECS --startport PORTNUM --endport PORTNUM --browserify --version ...]\n" +
"\n" +
"--platform PLATFORM : the platform id. Currently supports 'ios', 'browser', 'windows', 'android'.\n" +
"\tPath to platform can be specified as link to git repo like:\n" +
"\twindows@https://github.com/apache/cordova-windows.git\n" +
"\tor path to local copied git repo like:\n" +
"\twindows@../cordova-windows/\n" +
"`PATH` : the relative or absolute path to a plugin folder\n" +
"--plugin PATH : the relative or absolute path to a plugin folder\n" +
"\texpected to have a 'tests' folder.\n" +
"\tYou may specify multiple --plugin flags and they will all\n" +
"\tbe installed and tested together.\n" +
"`MSECS` : (optional) time in millisecs to wait for tests to pass|fail \n" +
"\t(defaults to 10 minutes) \n" +
"`PORTNUM` : (optional) ports to find available and use for posting results from emulator back to paramedic server(default is from 8008 to 8009)\n" +
"\n" +
"--browserify : (optional) plugins are browserified into cordova.js \n" +
"--buildName : (optional) Build name to show in Saucelabs dashboard\n" +
"--ci : (optional) Skip tests that require user interaction\n" +
Expand All @@ -53,13 +53,16 @@ var USAGE = "Error missing args. \n" +
"--sauceDeviceName : (optional) Name of the SauceLabs emulator/browser. For example, \"iPhone Simulator\" or \"firefox\"\n" +
"--sauceKey : (optional) Saucelabs access key\n" +
"--saucePlatformVersion : (optional) Version of the emulator OS or version of the browser. For example, \"9.3\" or \"54.0\"\n" +
"--sauceTunnelId : (optional) Tunnel identifier to use. Only usable if you have Sauce Connect up\n"
"--sauceTunnelId : (optional) Tunnel identifier to use. Only usable if you have Sauce Connect up\n" +
"--sauceUser : (optional) Saucelabs username\n" +
"--shouldUseSauce : (optional) run tests on Sauce Labs\n" +
"--skipAppiumTests : (optional) Do not run Appium tests\n" +
"--skipMainTests : (optional) Do not run main (cordova-test-framework) tests\n" +
"--startport/--endport `PORTNUM` : (optional) ports to find available and use for posting results from emulator back to paramedic server (default is from 8008 to 8009)\n" +
"--target : (optional) target to deploy to\n" +
"--tccDb : (optional) iOS only - specifies the path for the TCC.db file to be copied.\n" +
"--timeout `MSECS` : (optional) time in millisecs to wait for tests to pass|fail \n" +
"\t(defaults to 10 minutes) \n" +
"--useTunnel: (optional) use tunneling instead of local address. default is false\n" +
"--verbose : (optional) verbose mode. Display more information output\n" +
"--version : (optional) prints cordova-paramedic version and exits\n" +
Expand Down

0 comments on commit 9146804

Please sign in to comment.