1
+ /**
2
+ * @overview This script runs `electron-builder` with special management of code signing configuration on Windows.
3
+ * Running this script with no command line parameters should build all targets for the current platform.
4
+ * On Windows, make sure to set CSC_* or WIN_CSC_* environment variables or the NSIS build will fail.
5
+ * On Mac, the CSC_* variables are optional but will be respected if present.
6
+ * See also: https://www.electron.build/code-signing
7
+ */
8
+
1
9
const { spawnSync} = require ( 'child_process' ) ;
2
10
11
+ /**
12
+ * Strip any code signing configuration (CSC) from a set of environment variables.
13
+ * @param {object } environment - a collection of environment variables which might include code signing configuration.
14
+ * @returns {object } - a collection of environment variables which does not include code signing configuration.
15
+ */
3
16
const stripCSC = function ( environment ) {
4
17
const {
5
18
CSC_LINK : _CSC_LINK ,
@@ -11,15 +24,24 @@ const stripCSC = function (environment) {
11
24
return strippedEnvironment ;
12
25
} ;
13
26
27
+ /**
28
+ * @returns {string } - an `electron-builder` flag to build for the current platform, based on `process.platform`.
29
+ */
14
30
const getPlatformFlag = function ( ) {
15
31
switch ( process . platform ) {
16
32
case 'win32' : return '--windows' ;
17
33
case 'darwin' : return '--macos' ;
18
34
case 'linux' : return '--linux' ;
19
35
}
20
36
throw new Error ( `Could not determine platform flag for platform: ${ process . platform } ` ) ;
21
- }
37
+ } ;
22
38
39
+ /**
40
+ * Run `electron-builder` once to build one or more target(s).
41
+ * @param {string } targetGroup - the target(s) to build in this pass.
42
+ * If the `targetGroup` is `'nsis'` then the environment must contain code-signing config (CSC_* or WIN_CSC_*).
43
+ * If the `targetGroup` is `'appx'` then code-signing config will be stripped from the environment if present.
44
+ */
23
45
const runBuilder = function ( targetGroup ) {
24
46
// the appx build fails if CSC_* or WIN_CSC_* variables are set
25
47
const shouldStripCSC = ( targetGroup === 'appx' ) ;
@@ -37,6 +59,10 @@ const runBuilder = function (targetGroup) {
37
59
} ) ;
38
60
} ;
39
61
62
+ /**
63
+ * @returns {Array.<string> } - the default list of target groups on this platform. Each item in the array represents
64
+ * one call to `runBuilder` for one or more build target(s).
65
+ */
40
66
const calculateTargets = function ( ) {
41
67
switch ( process . platform ) {
42
68
case 'win32' :
0 commit comments