Skip to content

Commit

Permalink
Merge pull request TryGhost#1 from gristlabs/electron-support
Browse files Browse the repository at this point in the history
add support for ELECTRON_VERSION
  • Loading branch information
paulfitz authored Mar 14, 2018
2 parents e41129c + 4dec668 commit faf9be1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/sqlite3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
var binary = require('node-pre-gyp');
var path = require('path');
var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')));
// Tweak to pick correct binding_path when running under an electron forked process.
// If this PR gets merged, it will no longer be necessary.
// https://github.com/mapbox/node-pre-gyp/pull/343
var binding_options = {};
if (process.env.ELECTRON_VERSION) {
binding_options.runtime = 'electron';
binding_options.target = process.env.ELECTRON_VERSION;
}
var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')),
binding_options);
var binding = require(binding_path);
var sqlite3 = module.exports = exports = binding;
var EventEmitter = require('events').EventEmitter;
Expand Down
9 changes: 9 additions & 0 deletions test/electron.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var assert = require('assert');

describe('electron', function() {
it('respects ELECTRON_VERSION', function() {
process.env.ELECTRON_VERSION = '1.2.3';
assert.throws(function() { require('..'); },
(/Cannot find module .*\/node-sqlite3\/lib\/binding\/electron-v1.2-[^-]+-x64\/node_sqlite3.node/));
});
});

0 comments on commit faf9be1

Please sign in to comment.