Skip to content

Commit

Permalink
Add support for composer files in sub-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Dec 23, 2024
1 parent cdfde5e commit 84f76b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ Disable coverage for these reasons:
- The `php-version-file` input if it exists
- A `composer.lock` file and the `platform-overrides.php` value
- A `composer.json` file and the `config.platform.php` value
- If the `composer.lock` or `composer.json` file is in a sub-directory in your repository, please specify the subdirectory path in `COMPOSER_PROJECT_DIR` env.

#### `php-version-file` (optional)

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ export async function readPHPVersion(): Promise<string> {
throw new Error(`Could not find '${versionFile}' file.`);
}

const composerLock = 'composer.lock';
const composerProjectDir = await readEnv('COMPOSER_PROJECT_DIR');
const composerLock = path.join(composerProjectDir, 'composer.lock');
if (fs.existsSync(composerLock)) {
const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8'));
if (
Expand All @@ -452,7 +453,7 @@ export async function readPHPVersion(): Promise<string> {
}
}

const composerJson = 'composer.json';
const composerJson = path.join(composerProjectDir, 'composer.json');
if (fs.existsSync(composerJson)) {
const composerFileContents = JSON.parse(
fs.readFileSync(composerJson, 'utf8')
Expand Down

0 comments on commit 84f76b1

Please sign in to comment.