Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ declare class ElectronStore<T extends Record<string, any> = Record<string, unkno

/**
Open the storage file in the user's editor.

Returns a promise that resolves when the editor has been opened, or rejects if it failed to open.
*/
openInEditor(): void;
openInEditor(): Promise<void>;
}

export = ElectronStore;
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ class ElectronStore extends Conf {
initDataListener();
}

openInEditor() {
shell.openPath(this.path);
async openInEditor() {
const error = await shell.openPath(this.path);

if (error) {
throw new Error(error);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ store.reset('foo');
store.has('foo');
store.clear();

store.openInEditor();
await store.openInEditor();

store.size; // eslint-disable-line @typescript-eslint/no-unused-expressions
store.store; // eslint-disable-line @typescript-eslint/no-unused-expressions
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ Get the path to the storage file.

Open the storage file in the user's editor.

Returns a promise that resolves when the editor has been opened, or rejects if it failed to open.

### initRenderer()

Initializer to set up the required `ipc` communication channels for the module when a `Store` instance is not created in the main process and you are creating a `Store` instance in the Electron renderer process only.
Expand Down