Skip to content

Commit c327bc3

Browse files
author
Christopher Willis-Ford
committed
Add comments to electron-builder-wrapper.js
1 parent d077e79 commit c327bc3

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

scripts/electron-builder-wrapper.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
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+
19
const {spawnSync} = require('child_process');
210

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+
*/
316
const stripCSC = function (environment) {
417
const {
518
CSC_LINK: _CSC_LINK,
@@ -11,15 +24,24 @@ const stripCSC = function (environment) {
1124
return strippedEnvironment;
1225
};
1326

27+
/**
28+
* @returns {string} - an `electron-builder` flag to build for the current platform, based on `process.platform`.
29+
*/
1430
const getPlatformFlag = function () {
1531
switch (process.platform) {
1632
case 'win32': return '--windows';
1733
case 'darwin': return '--macos';
1834
case 'linux': return '--linux';
1935
}
2036
throw new Error(`Could not determine platform flag for platform: ${process.platform}`);
21-
}
37+
};
2238

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+
*/
2345
const runBuilder = function (targetGroup) {
2446
// the appx build fails if CSC_* or WIN_CSC_* variables are set
2547
const shouldStripCSC = (targetGroup === 'appx');
@@ -37,6 +59,10 @@ const runBuilder = function (targetGroup) {
3759
});
3860
};
3961

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+
*/
4066
const calculateTargets = function () {
4167
switch (process.platform) {
4268
case 'win32':

0 commit comments

Comments
 (0)