An open API service indexing awesome lists of open source software.

https://github.com/blahah/electron-sane-cachepath

set the electron cache path to a sane default for the current OS
https://github.com/blahah/electron-sane-cachepath

Last synced: 4 months ago
JSON representation

set the electron cache path to a sane default for the current OS

Awesome Lists containing this project

README

        

---


electron-sane-cachepath


set the electron cache path to a sane default for the current OS










---

Sets the `electron` and `chromium` app base cache paths to sane defaults:

- `macOS`: `~/Library/Caches`
- `windows`: `process.env.APPDATA`
- `linux`: `process.env.XDG_CACHE_HOME` or `~/.cache`

*note: the `cache` path is [now undocumented](https://github.com/electron/electron/commit/3d4318e15e757cf26377637ee1240d5b87cde39c) in `electron`, but it works as of electron `1.7.2`*

This module resolves the problem described in [this issue](https://github.com/electron/electron/issues/8124)

## Install

```
npm install --save electron-sane-cachepath
```

## Usage

Just pass your electron `app` to the module's exported function **before app emits 'ready'**.

``` js
const { app } = require('electron')
require('electron-sane-cachepath')(app)
```

An error will be thrown if:

- the `app` argument is missing
- the module is loaded in the renderer
- it is required on a platform other than `macOS`, `windows` or `linux`

## License

To the extent possible by law, we transfer any rights we have in this code to the public domain. Specifically, we do so using the [CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/).

You can do whatever you want with this code. No need to credit us, link to us, include any license, or anything else. But if you want to do those things, you're free to do that too.