-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement installers via electron-builder
- Loading branch information
Showing
5 changed files
with
360 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env node | ||
|
||
const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller | ||
const path = require('path') | ||
const rimraf = require('rimraf') | ||
|
||
deleteOutputFolder() | ||
.then(getInstallerConfig) | ||
.then(createWindowsInstaller) | ||
.catch((error) => { | ||
console.error(error.message || error) | ||
process.exit(1) | ||
}) | ||
|
||
function getInstallerConfig () { | ||
const rootPath = path.join(__dirname, '..') | ||
const outPath = path.join(rootPath, 'release') | ||
|
||
return Promise.resolve({ | ||
appDirectory: path.join(outPath, 'Mattermost-win32-ia32'), | ||
iconUrl: 'https://raw.githubusercontent.com/mattermost/desktop/master/resources/icon.ico', | ||
//loadingGif: path.join(rootPath, 'assets', 'img', 'loading.gif'), | ||
noMsi: true, | ||
outputDirectory: path.join(outPath, 'windows-installer'), | ||
setupExe: 'Mattermost.exe', | ||
setupIcon: path.join(rootPath, 'resources', 'icon.ico'), | ||
skipUpdateIcon: true, | ||
exe: 'Mattermost.exe' | ||
}) | ||
} | ||
|
||
function deleteOutputFolder () { | ||
return new Promise((resolve, reject) => { | ||
rimraf(path.join(__dirname, '..', 'out', 'windows-installer'), (error) => { | ||
error ? reject(error) : resolve() | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const ChildProcess = require('child_process') | ||
const path = require('path') | ||
|
||
exports.createShortcut = function (callback) { | ||
spawnUpdate([ | ||
'--createShortcut', | ||
path.basename(process.execPath), | ||
'--shortcut-locations', | ||
'StartMenu' | ||
], callback) | ||
} | ||
|
||
exports.removeShortcut = function (callback) { | ||
spawnUpdate([ | ||
'--removeShortcut', | ||
path.basename(process.execPath) | ||
], callback) | ||
} | ||
|
||
function spawnUpdate (args, callback) { | ||
var updateExe = path.resolve(process.execPath, '..', '..', 'Update.exe') | ||
var stdout = '' | ||
var spawned = null | ||
|
||
try { | ||
spawned = ChildProcess.spawn(updateExe, args) | ||
} catch (error) { | ||
if (error && error.stdout == null) error.stdout = stdout | ||
process.nextTick(function () { callback(error) }) | ||
return | ||
} | ||
|
||
var error = null | ||
|
||
spawned.stdout.on('data', function (data) { stdout += data }) | ||
|
||
spawned.on('error', function (processError) { | ||
if (!error) error = processError | ||
}) | ||
|
||
spawned.on('close', function (code, signal) { | ||
if (!error && code !== 0) { | ||
error = new Error('Command failed: ' + code + ' ' + signal) | ||
} | ||
if (error && error.code == null) error.code = code | ||
if (error && error.stdout == null) error.stdout = stdout | ||
callback(error) | ||
}) | ||
} |
Oops, something went wrong.