You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2020/07/15 14:17:47 UTC

[cordova-electron] branch master updated: fix(build): format top-level key for nsis-web (#158)

This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-electron.git


The following commit(s) were added to refs/heads/master by this push:
     new 6d70760  fix(build): format top-level key for nsis-web (#158)
6d70760 is described below

commit 6d707601757a3a85a464b4adce05fa60cfb39b4a
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Wed Jul 15 23:17:37 2020 +0900

    fix(build): format top-level key for nsis-web (#158)
---
 lib/build.js                      |  8 +++++++-
 tests/spec/unit/lib/build.spec.js | 27 +++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lib/build.js b/lib/build.js
index 00a0fba..9195285 100644
--- a/lib/build.js
+++ b/lib/build.js
@@ -29,6 +29,10 @@ const PLATFORM_MAPPING = {
     win: 'win32'
 };
 
+const TARGET_TOP_LEVEL_KEY_MAPPING = {
+    'nsis-web': 'nsisWeb'
+};
+
 class ElectronBuilder {
     constructor (buildOptions, api) {
         this.api = api;
@@ -120,7 +124,9 @@ class ElectronBuilder {
 
                 if (typeof target === 'object' && Object.keys(target).length !== 0) {
                     const targetKey = Object.keys(target)[0];
-                    userBuildSettings.config[targetKey] = target[targetKey];
+                    const rootKey = TARGET_TOP_LEVEL_KEY_MAPPING[targetKey] || targetKey;
+
+                    userBuildSettings.config[rootKey] = target[targetKey];
                     target = targetKey;
                 }
 
diff --git a/tests/spec/unit/lib/build.spec.js b/tests/spec/unit/lib/build.spec.js
index 372d18d..a07d14a 100644
--- a/tests/spec/unit/lib/build.spec.js
+++ b/tests/spec/unit/lib/build.spec.js
@@ -1261,6 +1261,33 @@ describe('Testing build.js:', () => {
             expect(buildOptions.buildConfig.electron.mac.signing.store.requirements).toBe(undefined);
         });
 
+        it('should format nsis-web taget with nsisWeb top-level configs in __formatAppendUserSettings.', () => {
+            // Sample target configuration option
+            const appPackageUrl = 'https://foo.bar/apps/win/web';
+            // The settings which will be populated by `__formatAppendUserSettings`
+            const userBuildSettings = {};
+            // platform config partial from `build.json`
+            const platformConfig = {
+                package: [
+                    { 'nsis-web': { appPackageUrl } }
+                ]
+            };
+            // the mock `build.json`
+            const buildConfig = { electron: { windows: platformConfig } };
+            // the build options which is passed from CLI/Lib to Platform Build
+            const buildOptions = { argv: [], buildConfig };
+
+            // // create spies
+            existsSyncSpy = jasmine.createSpy('existsSync').and.returnValue(false);
+            build.__set__('fs', { existsSync: existsSyncSpy });
+
+            electronBuilder = new ElectronBuilder(buildOptions, api)
+                .__formatAppendUserSettings('win', platformConfig, userBuildSettings);
+
+            expect(existsSyncSpy).toHaveBeenCalled();
+            expect(userBuildSettings.config.nsisWeb.appPackageUrl).toBe(appPackageUrl);
+        });
+
         it('should append user singing for windows', () => {
             // mock platformConfig, buildConfig and buildOptions Objects
             const platformConfig = {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org