Add support for composer files in sub-directory

This commit is contained in:
Shivam Mathur 2024-12-23 14:36:14 +05:30
parent cdfde5ebec
commit 84f76b1fc9
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
3 changed files with 5 additions and 3 deletions

View File

@ -416,6 +416,7 @@ Disable coverage for these reasons:
- The `php-version-file` input if it exists - The `php-version-file` input if it exists
- A `composer.lock` file and the `platform-overrides.php` value - A `composer.lock` file and the `platform-overrides.php` value
- A `composer.json` file and the `config.platform.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) #### `php-version-file` (optional)

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -441,7 +441,8 @@ export async function readPHPVersion(): Promise<string> {
throw new Error(`Could not find '${versionFile}' file.`); 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)) { if (fs.existsSync(composerLock)) {
const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8')); const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8'));
if ( if (
@ -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)) { if (fs.existsSync(composerJson)) {
const composerFileContents = JSON.parse( const composerFileContents = JSON.parse(
fs.readFileSync(composerJson, 'utf8') fs.readFileSync(composerJson, 'utf8')