How to test if composer.lock is up to date?

后端 未结 4 1512
谎友^
谎友^ 2021-02-20 01:46

During development (multiple people in the team) sometimes composer install returns:

Warning: The lock file is not up to date with the latest change

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 02:22

    For composer < 1.3.0

    Yes, there is a way to check for this very quickly.

    The "out-of-date" check is based on a hash of the composer.json contents, stored in the composer.lock. There's no salt, and it's a straight-forward hash of the contents, so it's very, very easy to do.

    hash;
    $json = md5(file_get_contents('composer.json'));
    
    if ($lock !== $json) {
        echo "Lock file out of date\n";
        exit(1);
    }
    
    echo "Lock file up to date\n";
    exit(0);
    

提交回复
热议问题