Skip to content

Commit

Permalink
add check to env-php-json if file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ejnshtein committed Jun 6, 2022
1 parent c795410 commit 43b6165
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion build-packages/magento-scripts/lib/util/env-php-json.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const path = require('path');
const UnknownError = require('../errors/unknown-error');
const pathExists = require('./path-exists');
const runPhpCode = require('./run-php');

const envPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
const { code, result } = await runPhpCode(`-r "echo json_encode(require '${path.join(projectPath, 'app', 'etc', 'env.php')}');"`, {
const envPhpPath = path.join(projectPath, 'app', 'etc', 'env.php');
if (!await pathExists(envPhpPath)) {
return null;
}
const { code, result } = await runPhpCode(`-r "echo json_encode(require '${envPhpPath}');"`, {
magentoVersion
});

Expand Down

0 comments on commit 43b6165

Please sign in to comment.