Преглед изворни кода

Added new build.overriddenProperties property (#125)

Franček Prijatelj пре 7 година
родитељ
комит
97c350accf
3 измењених фајлова са 7 додато и 1 уклоњено
  1. 1 0
      docs/Options.md
  2. 5 1
      src/lib/Builder.ts
  3. 1 0
      src/lib/config/BuildConfig.ts

+ 1 - 0
docs/Options.md

@@ -18,6 +18,7 @@ excludes | string[] | Glob patterns for excluded files. Defaults to `[]`.
 appId | string | App identity URI. Defaults to `io.github.nwjs.${ name }`.
 ffmpegIntegration | boolean | Whether to integrate `iteufel/nwjs-ffmpeg-prebuilt`. If `true`, you can NOT use symbols in `nwVersion`. Defaults to `false`.
 strippedProperties | string[] | Properties to be stripped from `package.json`. Defaults to `[ 'scripts', 'devDependencies', 'build' ]`.
+overriddenProperties | object | Reassigns the value of a property at the root of the `package.json` with the value given. Example: `"overriddenProperties": { "chromium-args": "--mixed-context" }`. In your build this would replace whatever chromium-args you were using during development. 
 
 ## build.win <- [WinConfig](../src/lib/config/WinConfig.ts)
 

+ 5 - 1
src/lib/Builder.ts

@@ -168,7 +168,11 @@ export class Builder {
 
         for(const key in pkg) {
             if(pkg.hasOwnProperty(key) && config.strippedProperties.indexOf(key) === -1) {
-                json[key] = pkg[key];
+                if (config.overriddenProperties && config.overriddenProperties.hasOwnProperty(key) ) {
+                    json[key] = config.overriddenProperties[key];
+                } else {
+                    json[key] = pkg[key];
+                }
             }
         }
 

+ 1 - 0
src/lib/config/BuildConfig.ts

@@ -26,6 +26,7 @@ export class BuildConfig {
     public appId: string = undefined;
     public ffmpegIntegration: boolean = false;
     public strippedProperties: string[] = [ 'scripts', 'devDependencies', 'build' ];
+    public overriddenProperties: any = {};
 
     constructor(pkg: any = {}) {