Skip to content

Commit

Permalink
Merge pull request #1122 from pulsar-edit/fix-better-sqlite-library
Browse files Browse the repository at this point in the history
Fixing requiring of better-sqlite3
  • Loading branch information
mauricioszabo authored Nov 5, 2024
2 parents 6e2674c + 6016688 commit c04a141
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

## [Unreleased]

- Fixed SQL State Storage not loading when starting Pulsar from a self-contained binary like appImage, tar.gz, etc.

## 1.122.0

- Added a SQL State Storage alternative to IndexedDB (opt-in, off by default).
Expand Down
3 changes: 2 additions & 1 deletion script/electron-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ let options = {
// Other Exclusions
"!**/._*",
"!**/node_modules/*.d.ts",
"!**/node_modules/**/*.map",
"!**/node_modules/.bin",
"!**/node_modules/native-mate",
"!node_modules/fuzzy-native/node_modules", // node_modules of the fuzzy-native package are only required for building it
"!node_modules/@pulsar-edit/fuzzy-native/node_modules", // node_modules of the fuzzy-native package are only required for building it
"!**/node_modules/spellchecker/vendor/hunspell/.*",
"!**/git-utils/deps",
"!**/oniguruma/deps",
Expand Down
10 changes: 8 additions & 2 deletions src/state-store/sql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict';

const sqlite3 = require('better-sqlite3');
const path = require('path');
const nativeSQLite = require(path.join(
require.resolve('better-sqlite3'),
'..', '..',
'build', 'Release',
'better_sqlite3.node'
));
const sqlite3 = require('better-sqlite3');

module.exports = class SQLStateStore {
constructor(databaseName, version) {
Expand All @@ -12,7 +18,7 @@ module.exports = class SQLStateStore {
const dbPath = path.join(atom.getConfigDirPath(), 'session-store.db');
let db;
try {
db = sqlite3(dbPath);
db = sqlite3(dbPath, {nativeBinding: nativeSQLite});
} catch(error) {
atom.notifications.addFatalError('Error loading database', {
stack: new Error('Error loading SQLite database for state storage').stack,
Expand Down

0 comments on commit c04a141

Please sign in to comment.