From 1aa183c3d567d4e9b05a1abb69327345ab834ffa Mon Sep 17 00:00:00 2001 From: Rostislav Khaniukov Date: Sat, 12 May 2018 18:40:17 +0300 Subject: [PATCH] Give ability to update dependencies block from preset --- src/Illuminate/Foundation/Console/Presets/Preset.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Foundation/Console/Presets/Preset.php b/src/Illuminate/Foundation/Console/Presets/Preset.php index acea75c22d71..ebdb79f9340e 100644 --- a/src/Illuminate/Foundation/Console/Presets/Preset.php +++ b/src/Illuminate/Foundation/Console/Presets/Preset.php @@ -25,19 +25,20 @@ protected static function ensureComponentDirectoryExists() * * @return void */ - protected static function updatePackages() + protected static function updatePackages($devDependency = true) { if (! file_exists(base_path('package.json'))) { return; } + $dependenciesBlock = $devDependency ? 'devDependencies' : 'dependencies'; $packages = json_decode(file_get_contents(base_path('package.json')), true); - $packages['devDependencies'] = static::updatePackageArray( - $packages['devDependencies'] + $packages[$dependenciesBlock] = static::updatePackageArray( + array_key_exists($dependenciesBlock, $packages) ? $packages[$dependenciesBlock] : [] ); - ksort($packages['devDependencies']); + ksort($packages[$dependenciesBlock]); file_put_contents( base_path('package.json'),