Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 31, 2018
1 parent 584c627 commit abffec0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
os:
- osx
- windows
language: node_js
node_js:
- 'node'
- '10'
- '8'
- '6'
4 changes: 2 additions & 2 deletions fixture-cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const electron = require('electron');
const Store = require('.');

// Prevent Electron from never exiting when an exception happens
process.on('uncaughtException', err => {
console.error('Exception:', err);
process.on('uncaughtException', error => {
console.error('Exception:', error);
process.exit(1);
});

Expand Down
4 changes: 2 additions & 2 deletions fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const electron = require('electron');
const Store = require('.');

// Prevent Electron from never exiting when an exception happens
process.on('uncaughtException', err => {
console.error('Exception:', err);
process.on('uncaughtException', error => {
console.error('Exception:', error);
process.exit(1);
});

Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ const electron = require('electron');
const Conf = require('conf');

class ElectronStore extends Conf {
constructor(opts) {
constructor(options) {
const defaultCwd = (electron.app || electron.remote.app).getPath('userData');

opts = Object.assign({name: 'config'}, opts);

if (opts.cwd) {
opts.cwd = path.isAbsolute(opts.cwd) ? opts.cwd : path.join(defaultCwd, opts.cwd);
if (options.cwd) {
options.cwd = path.isAbsolute(options.cwd) ? options.cwd : path.join(defaultCwd, options.cwd);
} else {
opts.cwd = defaultCwd;
options.cwd = defaultCwd;
}

opts.configName = opts.name;
delete opts.name;
super(opts);
options.configName = options.name;
delete options.name;
super(options);
}

openInEditor() {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"conf": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"electron": "^2.0.2",
"execa": "^0.10.0",
"xo": "*"
"ava": "^1.0.1",
"electron": "^4.0.0",
"execa": "^1.0.0",
"xo": "^0.23.0"
},
"xo": {
"envs": [
Expand Down
2 changes: 0 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Electron doesn't have a built-in way to persist user preferences and other data.

You can use this module directly in both the main and renderer process.

*[This project was previously known as `electron-config`.](https://github.com/sindresorhus/electron-store/issues/4)*


## Install

Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('main', async t => {

test('cwd option', async t => {
const result = await run('fixture-cwd.js');
const [defaultPath, storagePath, storagePath2] = result.split(/\r?\n/);
const [defaultPath, storagePath, storagePath2] = result.split('\n');
t.is(storagePath, path.join(defaultPath, 'foo/config.json'));
t.is(storagePath2, path.join(__dirname, 'bar/config.json'));
fs.unlinkSync(storagePath);
Expand Down

0 comments on commit abffec0

Please sign in to comment.