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'),