app: handle nativefier.json readonly access with options.maximize (#856)

**Resolves #855**

**Example result upon Terminal launch:**

`WARNING: Ignored nativefier.json rewrital (Error: EACCES: permission denied, open '/usr/lib/jupyter-remote-client/resources/app/nativefier.json')`

**Behaviour:**

+ Instead of crashing, the application properly opens and is always maximized.

+ When permissions are R/W, the application is maximized on first launch and the closing states are remembered by the OS throughout launches.
This commit is contained in:
Adrian DC 2019-10-23 01:36:40 +02:00 committed by Ronan Jouchet
parent e00f08e5d6
commit 84f06e3e79
1 changed files with 9 additions and 4 deletions

View File

@ -140,10 +140,15 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
if (options.maximize) {
mainWindow.maximize();
options.maximize = undefined;
fs.writeFileSync(
path.join(__dirname, '..', 'nativefier.json'),
JSON.stringify(options),
);
try {
fs.writeFileSync(
path.join(__dirname, '..', 'nativefier.json'),
JSON.stringify(options),
);
} catch (exception) {
// eslint-disable-next-line no-console
console.log(`WARNING: Ignored nativefier.json rewrital (${exception})`);
}
}
const withFocusedWindow = (block) => {