Skip to content

Commit

Permalink
Pass cwd to execute php
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed Mar 17, 2024
1 parent c473561 commit 11f6713
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/execPHP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { PHP_ERROR, PHP_TEMPLATE } from '../public'
import { dirname } from 'path'
import { exec } from 'child_process'
import fs from 'fs'

Expand Down Expand Up @@ -52,7 +53,7 @@ export class ExecPHP {
const cmd = `"${this.php}" "${absolutePath}"`

// https://nodejs.org/docs/latest-v18.x/api/child_process.html#child_processexeccommand-options-callback
exec(cmd, { maxBuffer: 1024 * 1024 * 2 }, function (error, stdout, stderr) {
exec(cmd, { maxBuffer: 1024 * 1024 * 2, cwd: dirname(absolutePath) }, function (error, stdout, stderr) {
if (error) returnWithError(`<p>error: ${error.message}</p>`, PHP_ERROR)
if (stderr) returnWithError(`<p>stderr: ${stderr}</p>`, PHP_ERROR)

Expand Down

0 comments on commit 11f6713

Please sign in to comment.