original_string: protected function updatePackages($packagesFile = '')
      {
          $packagesFile = $packagesFile ?: "{$this->sageRoot}/package.json";
          $packages = json_decode(file_get_contents($packagesFile), true);
          if (!$this->addOn) {
              $packages = $this->removePresetsFromPackagesArray($packages);
          }
          $packages = $this->updatePackagesArray($packages);
          ksort($packages['devDependencies']);
          ksort($packages['dependencies']);
          file_put_contents(
              $packagesFile,
              preg_replace_callback('/^ +/m', function ($matches) {
                  return str_repeat(' ', strlen($matches[0]) / 2);
              }, json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL)
          );
      }
code: protected function updatePackages($packagesFile = '')
      {
          $packagesFile = $packagesFile ?: "{$this->sageRoot}/package.json";
          $packages = json_decode(file_get_contents($packagesFile), true);
          if (!$this->addOn) {
              $packages = $this->removePresetsFromPackagesArray($packages);
          }
          $packages = $this->updatePackagesArray($packages);
          ksort($packages['devDependencies']);
          ksort($packages['dependencies']);
          file_put_contents(
              $packagesFile,
              preg_replace_callback('/^ +/m', function ($matches) {
                  return str_repeat(' ', strlen($matches[0]) / 2);
              }, json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL)
          );
      }
code_tokens: protected function updatePackages ( $ packagesFile = '' ) { $ packagesFile = $ packagesFile ? : "{$this->sageRoot}/package.json" ; $ packages = json_decode ( file_get_contents ( $ packagesFile ) , true ) ; if ( ! $ this -> addOn ) { $ packages = $ this -> removePresetsFromPackagesArray ( $ packages ) ; } $ packages = $ this -> updatePackagesArray ( $ packages ) ; ksort ( $ packages [ 'devDependencies' ] ) ; ksort ( $ packages [ 'dependencies' ] ) ; file_put_contents ( $ packagesFile , preg_replace_callback ( '/^ +/m' , function ( $ matches ) { return str_repeat ( ' ' , strlen ( $ matches [ 0 ] ) / 2 ) ; } , json_encode ( $ packages , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) . PHP_EOL ) ) ; }
docstring: Update package.json
  
  @param string $packagesFile Location of package.json
  @return void
docstring_tokens: Update package . json