Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect that the Electron app is running for the first time?

I'm developing an App using the latest version of Electron-builder (using AutoUpadate).

Is there any way to know that the App is running for the first time after installation?

Ps: I have tried using electron-config but the user data files are not deleted after uninstall, and I needed to do some things with every installation (even if it's on the same machine).

like image 664
Marcelo Romao Avatar asked Apr 30 '17 21:04

Marcelo Romao


People also ask

How do I check my Electron app?

Start recording a test by going to Test > Record > Record Keyword Test. Expand the Recording toolbar, click Run App, and then select the Electron application. Create Property Checkpoints by clicking Add Check. Checkpoints verify objects and values in the application that's being tested.

How do I close the Electron app?

If the user pressed Cmd + Q , or the developer called app. quit() , Electron will first try to close all the windows and then emit the will-quit event, and in this case the window-all-closed event would not be emitted.

What is Electron quick start?

Clone and run for a quick way to see Electron in action. This is a minimal Electron application based on the Quick Start Guide within the Electron documentation.


1 Answers

Check for the squirrel-firstrun flag:

var cmd = process.argv[1];

if (cmd == '--squirrel-firstrun') {
    // Running for the first time.
}

(you don't need to install anything for this to work)

Ref.

like image 147
Joshua Avatar answered Sep 19 '22 08:09

Joshua