Skip to content

Commit

Permalink
Fix php on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed Dec 2, 2024
1 parent 69a4bf6 commit 362efca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup PHP for macos
if: matrix.os == 'macos-latest'
uses: shivammathur/setup-php@v2
with:
tools: none

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
7 changes: 5 additions & 2 deletions src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ export const fileDoesExist = (path: string): Promise<boolean> => {
})
}

export const defaultPHPPath = () => {
export const defaultPHPPath = (is_ci: boolean = false) => {
// is_ci is for macos on github actions for shivammathur/setup-php@v2
// (https://github.com/marketplace/actions/setup-php-action)

switch (os.platform()) {
case 'darwin':
return '/usr/local/bin/php'
return is_ci ? '/opt/homebrew/bin/php' : '/usr/local/bin/php'
case 'linux':
return '/usr/bin/php'
case 'win32':
Expand Down
2 changes: 1 addition & 1 deletion test/execPHP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path')
const { defaultPHPPath } = require('../lib/misc')
const { ExecPHP } = require('../lib/utils/execPHP')

let phpPath = defaultPHPPath()
let phpPath = defaultPHPPath(true)

const PHP = new ExecPHP()
PHP.php = phpPath
Expand Down
2 changes: 1 addition & 1 deletion test/php.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const LiveServer = require('../lib').default

const liveServer = new LiveServer()

let phpPath = defaultPHPPath()
let phpPath = defaultPHPPath(true)

const open = async () => {
await liveServer.start({
Expand Down

0 comments on commit 362efca

Please sign in to comment.