Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 20c203b

Browse files
committed
minor #173 Update the composer.lock file to avoid out-of-sync errors (javiereguiluz)
This PR was squashed before being merged into the 1.0-dev branch (closes #173). Discussion ---------- Update the composer.lock file to avoid out-of-sync errors This fixes #172 Commits ------- 8ec7363 Update the composer.lock file to avoid out-of-sync errors
2 parents c8224d2 + 8ec7363 commit 20c203b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Symfony/Installer/NewCommand.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ protected function updateComposerJson()
336336

337337
file_put_contents($filename, json_encode($contents, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)."\n");
338338

339+
$this->syncComposerLockFile();
340+
339341
return $this;
340342
}
341343

@@ -412,4 +414,18 @@ protected function getRemoteFileUrl()
412414
{
413415
return 'http://symfony.com/download?v=Symfony_Standard_Vendors_'.$this->version;
414416
}
417+
418+
/**
419+
* Updates the 'hash' value stored in composer.lock to avoid out-of-sync
420+
* problems when the composer.json file contents are changed.
421+
*/
422+
private function syncComposerLockFile()
423+
{
424+
$composerFileContents = file_get_contents($this->projectDir.'/composer.json');
425+
$lockFileContents = json_decode(file_get_contents($this->projectDir.'/composer.lock'), true);
426+
427+
$lockFileContents['hash'] = md5($composerFileContents);
428+
429+
file_put_contents($this->projectDir.'/composer.lock', json_encode($lockFileContents, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)."\n");
430+
}
415431
}

0 commit comments

Comments
 (0)