如何测试composer.lock是否最新? [英] How to test if composer.lock is up to date?
问题描述
在开发过程中(团队中有多个人),有时个合成器安装
返回:
During development (multiple people in the team) sometimes composer install
returns:
警告:锁文件不是最新的composer.json更改。您可能会过时的依赖关系。运行更新以对其进行更新。
是否可以快速(以毫秒为单位)进行检查?
Is there a way to check for this very quickly (in milliseconds, without making any changes)?
我了解作曲家的工作方式。但是,当代码合并时,不一定会在 composer.json
或 composer.lock
文件上引起合并冲突,并且在几乎几乎没有任何更改并且该命令需要几分钟的时间的情况下,始终运行 composer install
并不是一件有趣的事情。
I understand how composer works. However when code merges in it doesn't necessarily cause merge conflicts on the composer.json
or composer.lock
file and it's not fun to run composer install
all the time when theres almost never any changes and that command takes several minutes.
如果我能够快速测试锁定失败是否不同步,可以将其构建到bash环境中以通知每个命令。类似于人们希望将其 git状态
内置到其bash提示符中的方式。
If I'm able to quick test if the lock fail has fallen out of sync I can build it into the bash environment to notify every command. Similar to how people like their git status
to be built into their bash prompt.
更重要的是, CI,以确保它确实潜入稳定分支。
Further more this makes sense in CI to make sure it does sneak it's way into the stable branch.
推荐答案
对于作曲家< 1.3.0
For composer < 1.3.0
从@Domster扩展到纯bash解决方案:
Extending from @Domster, the solution in pure bash:
COMPOSER_IN_SYNC=$(expr "`cat composer.lock | grep '"hash":' | cut -d'"' -f4`" = "`md5sum composer.json | cut -d ' ' -f 1`")
$ COMPOSER_IN_SYNC
分别为 0
或 1
。
这篇关于如何测试composer.lock是否最新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!