electron/spec/fixtures/api/singleton-userdata/main.js
Micha Hanselmann 78a3752ade
fix: create userData on requestSingleInstanceLock() if needed (#33559)
* test: use custom userData folder for requestSingleInstanceLock()

* update test

* prefix test folder path

* fix: create userDataDir on requestSingleInstanceLock() if needed

* Trigger Build
2022-04-04 10:39:55 +09:00

12 lines
506 B
JavaScript

const { app } = require('electron');
const fs = require('fs');
const path = require('path');
// non-existent user data folder should not break requestSingleInstanceLock()
// ref: https://github.com/electron/electron/issues/33547
const userDataFolder = path.join(app.getPath('home'), 'electron-test-singleton-userdata');
fs.rmSync(userDataFolder, { force: true, recursive: true });
app.setPath('userData', userDataFolder);
const gotTheLock = app.requestSingleInstanceLock();
app.exit(gotTheLock ? 0 : 1);