mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
try to fix export in electron
This commit is contained in:
parent
670e3d127e
commit
89dbf38962
@ -24,7 +24,7 @@ const requirePluginsTemplate = plugins =>
|
|||||||
|
|
||||||
const scriptTemplate = script => `
|
const scriptTemplate = script => `
|
||||||
const dbgateApi = require(process.env.DBGATE_API);
|
const dbgateApi = require(process.env.DBGATE_API);
|
||||||
dbgateApi.registerProcessCommunication();
|
dbgateApi.initializeApiEnvironment();
|
||||||
${requirePluginsTemplate(extractPlugins(script))}
|
${requirePluginsTemplate(extractPlugins(script))}
|
||||||
require=null;
|
require=null;
|
||||||
async function run() {
|
async function run() {
|
||||||
@ -37,7 +37,7 @@ dbgateApi.runScript(run);
|
|||||||
|
|
||||||
const loaderScriptTemplate = (functionName, props, runid) => `
|
const loaderScriptTemplate = (functionName, props, runid) => `
|
||||||
const dbgateApi = require(process.env.DBGATE_API);
|
const dbgateApi = require(process.env.DBGATE_API);
|
||||||
dbgateApi.registerProcessCommunication();
|
dbgateApi.initializeApiEnvironment();
|
||||||
${requirePluginsTemplate(extractShellApiPlugins(functionName, props))}
|
${requirePluginsTemplate(extractShellApiPlugins(functionName, props))}
|
||||||
require=null;
|
require=null;
|
||||||
async function run() {
|
async function run() {
|
||||||
@ -96,10 +96,10 @@ module.exports = {
|
|||||||
console.log(`RUNNING SCRIPT ${scriptFile}`);
|
console.log(`RUNNING SCRIPT ${scriptFile}`);
|
||||||
// const subprocess = fork(scriptFile, ['--checkParent', '--max-old-space-size=8192'], {
|
// const subprocess = fork(scriptFile, ['--checkParent', '--max-old-space-size=8192'], {
|
||||||
const subprocess = fork(scriptFile, ['--checkParent', ...process.argv.slice(3)], {
|
const subprocess = fork(scriptFile, ['--checkParent', ...process.argv.slice(3)], {
|
||||||
cwd: directory,
|
|
||||||
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
||||||
env: {
|
env: {
|
||||||
DBGATE_API: process.argv[1],
|
DBGATE_API: process.argv[1],
|
||||||
|
DBGATE_CWD: directory,
|
||||||
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, path.join(pluginsdir(), name)])),
|
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, path.join(pluginsdir(), name)])),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@ const requirePlugin = require('./requirePlugin');
|
|||||||
const download = require('./download');
|
const download = require('./download');
|
||||||
const executeQuery = require('./executeQuery');
|
const executeQuery = require('./executeQuery');
|
||||||
const loadFile = require('./loadFile');
|
const loadFile = require('./loadFile');
|
||||||
const registerProcessCommunication = require('./registerProcessCommunication');
|
const initializeApiEnvironment = require('./initializeApiEnvironment');
|
||||||
|
|
||||||
const dbgateApi = {
|
const dbgateApi = {
|
||||||
queryReader,
|
queryReader,
|
||||||
@ -38,7 +38,7 @@ const dbgateApi = {
|
|||||||
registerPlugins,
|
registerPlugins,
|
||||||
executeQuery,
|
executeQuery,
|
||||||
loadFile,
|
loadFile,
|
||||||
registerProcessCommunication,
|
initializeApiEnvironment,
|
||||||
};
|
};
|
||||||
|
|
||||||
requirePlugin.initializeDbgateApi(dbgateApi);
|
requirePlugin.initializeDbgateApi(dbgateApi);
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
const { handleProcessCommunication } = require('../utility/processComm');
|
const { handleProcessCommunication } = require('../utility/processComm');
|
||||||
|
|
||||||
async function registerProcessCommunication() {
|
async function initializeApiEnvironment() {
|
||||||
process.on('message', async message => {
|
process.on('message', async message => {
|
||||||
handleProcessCommunication(message);
|
handleProcessCommunication(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (process.env.DBGATE_CWD) {
|
||||||
|
process.chdir(process.env.DBGATE_CWD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = registerProcessCommunication;
|
module.exports = initializeApiEnvironment;
|
Loading…
Reference in New Issue
Block a user