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 dbgateApi = require(process.env.DBGATE_API);
|
||||
dbgateApi.registerProcessCommunication();
|
||||
dbgateApi.initializeApiEnvironment();
|
||||
${requirePluginsTemplate(extractPlugins(script))}
|
||||
require=null;
|
||||
async function run() {
|
||||
@ -37,7 +37,7 @@ dbgateApi.runScript(run);
|
||||
|
||||
const loaderScriptTemplate = (functionName, props, runid) => `
|
||||
const dbgateApi = require(process.env.DBGATE_API);
|
||||
dbgateApi.registerProcessCommunication();
|
||||
dbgateApi.initializeApiEnvironment();
|
||||
${requirePluginsTemplate(extractShellApiPlugins(functionName, props))}
|
||||
require=null;
|
||||
async function run() {
|
||||
@ -96,10 +96,10 @@ module.exports = {
|
||||
console.log(`RUNNING SCRIPT ${scriptFile}`);
|
||||
// const subprocess = fork(scriptFile, ['--checkParent', '--max-old-space-size=8192'], {
|
||||
const subprocess = fork(scriptFile, ['--checkParent', ...process.argv.slice(3)], {
|
||||
cwd: directory,
|
||||
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
||||
env: {
|
||||
DBGATE_API: process.argv[1],
|
||||
DBGATE_CWD: directory,
|
||||
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, path.join(pluginsdir(), name)])),
|
||||
},
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ const requirePlugin = require('./requirePlugin');
|
||||
const download = require('./download');
|
||||
const executeQuery = require('./executeQuery');
|
||||
const loadFile = require('./loadFile');
|
||||
const registerProcessCommunication = require('./registerProcessCommunication');
|
||||
const initializeApiEnvironment = require('./initializeApiEnvironment');
|
||||
|
||||
const dbgateApi = {
|
||||
queryReader,
|
||||
@ -38,7 +38,7 @@ const dbgateApi = {
|
||||
registerPlugins,
|
||||
executeQuery,
|
||||
loadFile,
|
||||
registerProcessCommunication,
|
||||
initializeApiEnvironment,
|
||||
};
|
||||
|
||||
requirePlugin.initializeDbgateApi(dbgateApi);
|
||||
|
@ -1,9 +1,13 @@
|
||||
const { handleProcessCommunication } = require('../utility/processComm');
|
||||
|
||||
async function registerProcessCommunication() {
|
||||
async function initializeApiEnvironment() {
|
||||
process.on('message', async 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