Skip to content

Commit f7d0b6e

Browse files
committed
INT-250 windows build: add check for SIGNTOOL_PARAMS
1 parent 08de584 commit f7d0b6e

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tasks/win32.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
var path = require('path');
33
var pkg = require(path.resolve(__dirname, '../package.json'));
44
var fs = require('fs');
5+
var format = require('util').format;
6+
var chalk = require('chalk');
7+
var figures = require('figures');
58
var packager = require('electron-packager');
69
var createInstaller = require('electron-installer-squirrel-windows');
710
var debug = require('debug')('scout:tasks:win32');
811

12+
913
var APP_PATH = path.resolve(__dirname, '../dist/MongoDBCompass-win32-x64');
1014
module.exports.ELECTRON = path.join(APP_PATH, 'MongoDBCompass.exe');
1115
module.exports.RESOURCES = path.join(APP_PATH, 'resources');
@@ -38,6 +42,24 @@ var INSTALLER_CONFIG = {
3842
overwrite: true
3943
};
4044

45+
/**
46+
* Checks if the current environment can actually sign builds.
47+
* If signing can be done, `electron-installer-squirrel-windows`'s config
48+
* will be updated to sign artifacts. If not, gracefully degrade
49+
*
50+
* @param {Function} fn - Callback.
51+
*/
52+
function addCodesignIdentityIfAvailable(fn) {
53+
if (process.env.SIGNTOOL_PARAMS) {
54+
INSTALLER_CONFIG.sign_with_params = process.env.SIGNTOOL_PARAMS;
55+
console.log(chalk.green.bold(figures.tick),
56+
format(' This build will be signed using signtool.exe `%s`',
57+
INSTALLER_CONFIG.sign_with_params));
58+
}
59+
fn();
60+
return;
61+
}
62+
4163
module.exports.build = function(done) {
4264
fs.exists(APP_PATH, function(exists) {
4365
if (exists) {
@@ -56,11 +78,16 @@ module.exports.build = function(done) {
5678
};
5779

5880
module.exports.installer = function(done) {
59-
createInstaller(INSTALLER_CONFIG, function(err) {
81+
addCodesignIdentityIfAvailable(function(err) {
6082
if (err) {
6183
return done(err);
6284
}
63-
console.log('Installer created!');
64-
done();
85+
createInstaller(INSTALLER_CONFIG, function(err2) {
86+
if (err2) {
87+
return done(err2);
88+
}
89+
console.log('Installer created!');
90+
done();
91+
});
6592
});
6693
};

0 commit comments

Comments
 (0)