Skip to content

Commit

Permalink
✨ Add support for electron-store's migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
BetaHuhn committed May 27, 2021
1 parent a4bc840 commit 6a62a6e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PersistedState {
checkStorage: true
};
if (!opts.storage) {
defaultOptions.storage = new electron_store_1.default(Object.assign(Object.assign({ name: defaultOptions.fileName }, (opts.encryptionKey && { encryptionKey: opts.encryptionKey })), (opts.storageFileLocation && { cwd: opts.storageFileLocation })));
defaultOptions.storage = new electron_store_1.default(Object.assign(Object.assign(Object.assign({ name: defaultOptions.fileName }, (opts.encryptionKey && { encryptionKey: opts.encryptionKey })), (opts.storageFileLocation && { cwd: opts.storageFileLocation })), (opts.migrations && { migrations: opts.migrations })));
}
this.opts = Object.assign({}, defaultOptions, opts);
this.store = store;
Expand Down
2 changes: 1 addition & 1 deletion lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Store, { Options as StoreOptions } from 'electron-store';
import { MutationPayload } from 'vuex';
import { SetRequired } from 'type-fest';
import { Options as DeepmergeOptions } from 'deepmerge';
export interface Options<T> extends Pick<StoreOptions<T>, 'encryptionKey'> {
export interface Options<T> extends Pick<StoreOptions<T>, 'migrations' | 'encryptionKey'> {
fileName?: StoreOptions<T>['name'];
storageKey?: string;
paths?: string[];
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class PersistedState<State extends Record<string, any> = Record<string, unknown>
defaultOptions.storage = new Store({
name: defaultOptions.fileName,
...(opts.encryptionKey && { encryptionKey: opts.encryptionKey }),
...(opts.storageFileLocation && { cwd: opts.storageFileLocation })
...(opts.storageFileLocation && { cwd: opts.storageFileLocation }),
...(opts.migrations && { migrations: opts.migrations })
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MutationPayload } from 'vuex'
import { SetRequired } from 'type-fest'
import { Options as DeepmergeOptions } from 'deepmerge'

export interface Options<T> extends Pick<StoreOptions<T>, 'encryptionKey'> {
export interface Options<T> extends Pick<StoreOptions<T>, 'migrations' | 'encryptionKey'> {
fileName?: StoreOptions<T>['name'];
storageKey?: string;
paths?: string[];
Expand Down

0 comments on commit 6a62a6e

Please sign in to comment.