Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/context menu helper #140

Merged
merged 20 commits into from
Dec 1, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
tidy
gwleuverink committed Nov 16, 2024
commit 9b7ca516be117f61e0899e0c17b3b6a79a7b08a2
46 changes: 25 additions & 21 deletions resources/js/electron-plugin/src/server/api/childProcess.ts
Original file line number Diff line number Diff line change
@@ -95,6 +95,30 @@ function startProcess(settings) {
};
}

function startPhpProcess(settings) {
const defaultEnv = getDefaultEnvironmentVariables(
state.randomSecret,
state.electronApiPort
);

// Construct command args from ini settings
const iniSettings = { ...getDefaultPhpIniSettings(), ...state.phpIni };
const iniArgs = Object.keys(iniSettings).map(key => {
return ['-d', `${key}=${iniSettings[key]}`];
}).flat();


settings = {
...settings,
// Prepend cmd with php executable path & ini settings
cmd: [ state.php, ...iniArgs, ...settings.cmd ],
// Mix in the internal NativePHP env
env: { ...settings.env, ...defaultEnv }
};

return startProcess(settings);
}

function stopProcess(alias) {
const proc = getProcess(alias);

@@ -132,27 +156,7 @@ router.post('/start', (req, res) => {
});

router.post('/start-php', (req, res) => {
const defaultEnv = getDefaultEnvironmentVariables(
state.randomSecret,
state.electronApiPort
);

// Construct command args from ini settings
const iniSettings = { ...getDefaultPhpIniSettings(), ...state.phpIni };
const iniArgs = Object.keys(iniSettings).map(key => {
return ['-d', `${key}=${iniSettings[key]}`];
}).flat();


let settings = {
...req.body,
// Prepend cmd with php executable path & ini settings
cmd: [ state.php, ...iniArgs, ...req.body.cmd ],
// Mix in the internal NativePHP env
env: { ...req.body.env, ...defaultEnv }
};

const proc = startProcess(settings);
const proc = startPhpProcess(req.body);

res.json(proc);
});