Created
September 6, 2017 22:28
-
-
Save akashnimare/2b0d1abbb303f2a3159821322d40d091 to your computer and use it in GitHub Desktop.
Clearing application data in Electron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const { app } = require('electron'); | |
const fs = require('fs-extra'); | |
const appName = app.getName(); | |
// Get app directory | |
// on OSX it's /Users/Yourname/Library/Application Support/AppName | |
const getAppPath = path.join(app.getPath('appData'), appName); | |
fs.unlink(getAppPath, () => { | |
// callback | |
alert("App data cleared"); | |
// You should relaunch the app after clearing the app settings. | |
app.relaunch(); | |
app.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment