harness-push: Allow pushes without config.xml
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/de2743ec Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/de2743ec Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/de2743ec Branch: refs/heads/master Commit: de2743ec8306b43e292127ad77eef73d8c89d221 Parents: 68e7118 Author: Andrew Grieve <[email protected]> Authored: Mon May 26 15:00:54 2014 -0400 Committer: Andrew Grieve <[email protected]> Committed: Mon May 26 15:00:54 2014 -0400 ---------------------------------------------------------------------- .../cordova-harness-client/pushsession.js | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/de2743ec/harness-push/node_modules/cordova-harness-client/pushsession.js ---------------------------------------------------------------------- diff --git a/harness-push/node_modules/cordova-harness-client/pushsession.js b/harness-push/node_modules/cordova-harness-client/pushsession.js index 546978b..23934f7 100644 --- a/harness-push/node_modules/cordova-harness-client/pushsession.js +++ b/harness-push/node_modules/cordova-harness-client/pushsession.js @@ -109,11 +109,13 @@ function buildAssetManifest(dir, configXmlPath) { etag: calculateMd5(fileList[i]), }; } - ret['config.xml'] = { - path: 'config.xml', - realPath: configXmlPath, - etag: calculateMd5(configXmlPath) - }; + if (configXmlPath) { + ret['config.xml'] = { + path: 'config.xml', + realPath: configXmlPath, + etag: calculateMd5(configXmlPath) + }; + } return ret; } @@ -171,8 +173,8 @@ function zipDir(dir, zip) { function PushSession(harnessClient, dir) { this.launchAfterPush = true; - this.appType_ = 'cordova'; this.harnessClient_ = harnessClient; + this.appType_ = null; this.rootDir_ = dir; this.wwwDir_ = null; this.appId_ = null; @@ -195,8 +197,9 @@ PushSession.prototype.initialize = function(opts) { self.assetManifest_ = result.body['assetManifest']; self.assetManifestEtag_ = result.body['assetManifestEtag']; self.wwwDir_ = opts.wwwDir || getDerivedWwwDir(self.rootDir_, self.platformId_); - self.configXmlPath_ = opts.configXmlPath || getDerivedConfigXmlPath(self.rootDir_, self.platformId_); + self.configXmlPath_ = (typeof opts.configXmlPath == 'undefined') ? getDerivedConfigXmlPath(self.rootDir_, self.platformId_) : opts.configXmlPath; self.cordovaPluginsPath_ = !opts.skipCordovaPlugins && path.join(self.wwwDir_, 'cordova_plugins.js'); + self.appType_ = opts.appType || 'cordova'; }); }; @@ -204,7 +207,7 @@ PushSession.prototype.push = function() { var self = this; return Q.when(this.platformId_ || this.initialize()) .then(function() { - if (!fs.existsSync(self.configXmlPath_)) { + if (self.configXmlPath_ && !fs.existsSync(self.configXmlPath_)) { throw new Error('Could not find: ' + self.configXmlPath_ + ' you probably need to run: cordova platform add ' + self.platformId_); } if (self.cordovaPluginsPath_ && !fs.existsSync(self.cordovaPluginsPath_)) { @@ -260,7 +263,9 @@ PushSession.prototype.doFileSync_ = function() { PushSession.prototype.doZipPush_ = function() { var zip = new JSZip(); zipDir(this.wwwDir_, zip.folder('www')); - zip.file('config.xml', fs.readFileSync(this.configXmlPath_, 'binary'), { binary: true }); + if (this.configXmlPath_) { + zip.file('config.xml', fs.readFileSync(this.configXmlPath_, 'binary'), { binary: true }); + } var newAssetManifest = buildAssetManifest(this.wwwDir_, this.configXmlPath_); zip.file('zipassetmanifest.json', JSON.stringify(newAssetManifest)); var zipData = new Buffer(zip.generate({ type: 'base64' }), 'base64');
