mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-19 23:17:16 +03:00
Create get-app-name module that returns correct application name
Before, in order to retrieve the application name, Electron's `getName()` method was used (https://electronjs.org/docs/api/app#appgetname). Now, instead, we also use the Atom version in order to calculate the release channel and be able to have it on the app name (e.g `Atom Nightly`).
This commit is contained in:
parent
0578c0626e
commit
f7b7545fd0
@ -97,7 +97,7 @@ describe('AtomWindow', function() {
|
|||||||
const { browserWindow } = w;
|
const { browserWindow } = w;
|
||||||
|
|
||||||
assert.isFalse(browserWindow.isVisible());
|
assert.isFalse(browserWindow.isVisible());
|
||||||
assert.strictEqual(browserWindow.getTitle(), 'Atom');
|
assert.isTrue(browserWindow.getTitle().startsWith('Atom'));
|
||||||
|
|
||||||
const settings = JSON.parse(browserWindow.loadSettingsJSON);
|
const settings = JSON.parse(browserWindow.loadSettingsJSON);
|
||||||
assert.strictEqual(settings.userSettings, 'stub-config');
|
assert.strictEqual(settings.userSettings, 'stub-config');
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const { BrowserWindow, app, dialog, ipcMain } = require('electron');
|
const { BrowserWindow, app, dialog, ipcMain } = require('electron');
|
||||||
|
const getAppName = require('./get-app-name');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
const { EventEmitter } = require('events');
|
const { EventEmitter } = require('events');
|
||||||
@ -35,7 +36,7 @@ module.exports = class AtomWindow extends EventEmitter {
|
|||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
show: false,
|
show: false,
|
||||||
title: app.getName(),
|
title: getAppName(),
|
||||||
tabbingIdentifier: 'atom',
|
tabbingIdentifier: 'atom',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
// Prevent specs from throttling when the window is in the background:
|
// Prevent specs from throttling when the window is in the background:
|
||||||
@ -80,7 +81,7 @@ module.exports = class AtomWindow extends EventEmitter {
|
|||||||
|
|
||||||
this.loadSettings = Object.assign({}, settings);
|
this.loadSettings = Object.assign({}, settings);
|
||||||
this.loadSettings.appVersion = app.getVersion();
|
this.loadSettings.appVersion = app.getVersion();
|
||||||
this.loadSettings.appName = app.getName();
|
this.loadSettings.appName = getAppName();
|
||||||
this.loadSettings.resourcePath = this.resourcePath;
|
this.loadSettings.resourcePath = this.resourcePath;
|
||||||
this.loadSettings.atomHome = process.env.ATOM_HOME;
|
this.loadSettings.atomHome = process.env.ATOM_HOME;
|
||||||
if (this.loadSettings.devMode == null) this.loadSettings.devMode = false;
|
if (this.loadSettings.devMode == null) this.loadSettings.devMode = false;
|
||||||
|
15
src/main-process/get-app-name.js
Normal file
15
src/main-process/get-app-name.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const { app } = require('electron');
|
||||||
|
const getReleaseChannel = require('../get-release-channel');
|
||||||
|
|
||||||
|
module.exports = function getAppName() {
|
||||||
|
const releaseChannel = getReleaseChannel(app.getVersion());
|
||||||
|
const appNameParts = [app.getName()];
|
||||||
|
|
||||||
|
if (releaseChannel !== 'stable') {
|
||||||
|
appNameParts.push(
|
||||||
|
releaseChannel.charAt(0).toUpperCase() + releaseChannel.slice(1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return appNameParts.join(' ');
|
||||||
|
};
|
@ -1,5 +1,6 @@
|
|||||||
let setxPath;
|
let setxPath;
|
||||||
const fs = require('fs-plus');
|
const fs = require('fs-plus');
|
||||||
|
const getAppName = require('./get-app-name');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Spawner = require('./spawner');
|
const Spawner = require('./spawner');
|
||||||
const WinShell = require('./win-shell');
|
const WinShell = require('./win-shell');
|
||||||
@ -182,25 +183,27 @@ exports.restartAtom = app => {
|
|||||||
// Handle squirrel events denoted by --squirrel-* command line arguments.
|
// Handle squirrel events denoted by --squirrel-* command line arguments.
|
||||||
exports.handleStartupEvent = (app, squirrelCommand) => {
|
exports.handleStartupEvent = (app, squirrelCommand) => {
|
||||||
const exeName = getExeName(app);
|
const exeName = getExeName(app);
|
||||||
|
const appName = getAppName();
|
||||||
|
|
||||||
switch (squirrelCommand) {
|
switch (squirrelCommand) {
|
||||||
case '--squirrel-install':
|
case '--squirrel-install':
|
||||||
createShortcuts(exeName, ['Desktop', 'StartMenu'], () =>
|
createShortcuts(exeName, ['Desktop', 'StartMenu'], () =>
|
||||||
addCommandsToPath(exeName, () =>
|
addCommandsToPath(exeName, () =>
|
||||||
WinShell.registerShellIntegration(app.getName(), () => app.quit())
|
WinShell.registerShellIntegration(appName, () => app.quit())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
case '--squirrel-updated':
|
case '--squirrel-updated':
|
||||||
updateShortcuts(app.getName(), exeName, () =>
|
updateShortcuts(appName, exeName, () =>
|
||||||
addCommandsToPath(exeName, () =>
|
addCommandsToPath(exeName, () =>
|
||||||
WinShell.updateShellIntegration(app.getName(), () => app.quit())
|
WinShell.updateShellIntegration(appName, () => app.quit())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
case '--squirrel-uninstall':
|
case '--squirrel-uninstall':
|
||||||
removeShortcuts(exeName, () =>
|
removeShortcuts(exeName, () =>
|
||||||
removeCommandsFromPath(() =>
|
removeCommandsFromPath(() =>
|
||||||
WinShell.deregisterShellIntegration(app.getName(), () => app.quit())
|
WinShell.deregisterShellIntegration(appName, () => app.quit())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const Registry = require('winreg');
|
const Registry = require('winreg');
|
||||||
const Path = require('path');
|
const Path = require('path');
|
||||||
|
const getAppName = require('./get-app-name');
|
||||||
|
|
||||||
let exeName = Path.basename(process.execPath);
|
let exeName = Path.basename(process.execPath);
|
||||||
let appPath = `"${process.execPath}"`;
|
let appPath = `"${process.execPath}"`;
|
||||||
@ -136,6 +137,7 @@ function deregisterShellIntegration(appName, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
appName: getAppName(),
|
||||||
registerShellIntegration,
|
registerShellIntegration,
|
||||||
updateShellIntegration,
|
updateShellIntegration,
|
||||||
deregisterShellIntegration
|
deregisterShellIntegration
|
||||||
|
Loading…
Reference in New Issue
Block a user