Merge pull request #4805 from atom/automatically-set-app-model-id
Automatically set app user model ID
This commit is contained in:
commit
242be31440
1 changed files with 29 additions and 0 deletions
|
@ -78,6 +78,35 @@ app.on('quit', function(event, exitCode) {
|
|||
return process.emit('exit', exitCode);
|
||||
});
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// If we are a Squirrel.Windows-installed app, set app user model ID
|
||||
// so that users don't have to do this.
|
||||
//
|
||||
// Squirrel packages are always of the form:
|
||||
//
|
||||
// PACKAGE-NAME
|
||||
// - Update.exe
|
||||
// - app-VERSION
|
||||
// - OUREXE.exe
|
||||
//
|
||||
// Squirrel itself will always set the shortcut's App User Model ID to the
|
||||
// form `com.squirrel.PACKAGE-NAME.OUREXE`. We need to call
|
||||
// app.setAppUserModelId with a matching identifier so that renderer processes
|
||||
// will inherit this value.
|
||||
var updateDotExe = path.join(
|
||||
path.dirname(process.execPath),
|
||||
'..',
|
||||
'update.exe');
|
||||
|
||||
if (fs.statSyncNoException(updateDotExe)) {
|
||||
var packageDir = path.dirname(path.resolve(updateDotExe));
|
||||
var packageName = path.basename(packageDir);
|
||||
var exeName = path.basename(process.execPath).replace(/\.exe$/i, '');
|
||||
|
||||
app.setAppUserModelId(`com.squirrel.${packageName}.${exeName}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Map process.exit to app.exit, which quits gracefully.
|
||||
process.exit = app.exit;
|
||||
|
||||
|
|
Loading…
Reference in a new issue