Skip to content

Commit

Permalink
Give ability to update dependencies block from preset
Browse files Browse the repository at this point in the history
  • Loading branch information
nulpatrol committed May 12, 2018
1 parent 4266414 commit 1aa183c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Illuminate/Foundation/Console/Presets/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 1aa183c

Please sign in to comment.