RobLoach / component-installer

Install Web Components through Composer
https://asset-packagist.org/
Other
280 stars 35 forks source link

Strengthening checks around Locker use. #84

Closed moufmouf closed 9 years ago

moufmouf commented 9 years ago

Hi Rob,

I just changed the way you check if the locker is available or not in the "init()" method. At this point in the process, since we are in post-dump-autoload, we should be safe to assume that the lockfile is created. Therefore, the test as you wrote (if (isset(($locker)) {...}) should always be true.

However, in very special circumstances (like when you are using EmbeddedComposer, there can be really no lock file. The test is still true, but the call to $locker->getLockData() throws an exception (lock file not found). The piece of code I added actually checks that the lock file exists, and the test fails if the lock file does not exist (or if it contains no packages).

RobLoach commented 9 years ago

:+1: Thanks a lot. Looks good to me.