Skip to content

Commit

Permalink
handle a case when composer.json config field is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
ejnshtein committed Feb 9, 2022
1 parent fae410d commit e93821b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const enableMagentoComposerPlugins = () => ({
const {
config: {
'allow-plugins': allowPlugins = {}
}
} = {}
} = composerJsonData;
const allowPluginsKeys = Object.keys(allowPlugins);

Expand Down Expand Up @@ -110,7 +110,7 @@ Do you want to enable them all or disable some of them?`,

if (userConfirmation) {
composerJsonData.config = {
...composerJsonData.config,
...(composerJsonData.config || {}),
'allow-plugins': {
...allowPlugins,
...missingPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
Expand Down Expand Up @@ -141,7 +141,7 @@ Do you want to enable them all or disable some of them?`,
const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));

composerJsonData.config = {
...composerJsonData.config,
...(composerJsonData.config || {}),
'allow-plugins': {
...allowPlugins,
...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
Expand Down

0 comments on commit e93821b

Please sign in to comment.