From df5a82609c8ac613167cb97bf238ca527a861ecd Mon Sep 17 00:00:00 2001 From: sebv Date: Mon, 31 Aug 2015 16:38:13 +0800 Subject: [PATCH] cleaning app opt at the beginning --- lib/commands/session.js | 6 ++++++ lib/helpers.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/commands/session.js b/lib/commands/session.js index 5d241d45c..f44cba305 100644 --- a/lib/commands/session.js +++ b/lib/commands/session.js @@ -20,6 +20,12 @@ commands.createSession = async function (caps) { // merge caps onto opts so we don't need to worry about what's where Object.assign(this.opts, this.caps); + + // Prevents empty string caps so we don't need to test it everywhere + if (typeof this.opts.app === 'string' && this.opts.app.trim() === '') { + this.opts.app = null; + } + if (!_.isUndefined(this.caps.newCommandTimeout)) { this.newCommandTimeoutMs = (this.caps.newCommandTimeout * 1000); } diff --git a/lib/helpers.js b/lib/helpers.js index b5d85fd14..a4dd70de7 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -12,9 +12,11 @@ import request from 'request'; const ZIP_EXTS = ['.zip', '.ipa']; async function configureApp (app, appExt) { + if (_.isNull(app) || _.isUndefined(app)) { return; } + let newApp = null; let shouldUnzipApp = _.contains(ZIP_EXTS, path.extname(app)); - if (app.substring(0, 4).toLowerCase() === "http") { + if ((app || '').substring(0, 4).toLowerCase() === "http") { logger.info(`Using downloadable app ${app}`); newApp = await downloadApp(app, shouldUnzipApp ? ".zip" : appExt); logger.info(`Downloaded app to ${newApp}`);