File tree 2 files changed +24
-2
lines changed
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -67,9 +67,12 @@ public function canRunInContext(ContextInterface $context): bool
67
67
public function run (ContextInterface $ context ): TaskResultInterface
68
68
{
69
69
$ config = $ this ->getConfig ()->getOptions ();
70
+ $ composerDir = pathinfo ($ config ['file ' ], PATHINFO_DIRNAME );
71
+ $ composerFile = pathinfo ($ config ['file ' ], PATHINFO_BASENAME );
72
+ $ composerLockFile = $ this ->getLockFile ($ composerFile );
70
73
$ files = $ context ->getFiles ()
71
- ->path (pathinfo ( $ config [ ' file ' ], PATHINFO_DIRNAME ) )
72
- ->name ( pathinfo ( $ config [ ' file ' ], PATHINFO_BASENAME ) );
74
+ ->path ($ composerDir )
75
+ ->names ([ $ composerFile , $ composerLockFile ] );
73
76
if (0 === \count ($ files )) {
74
77
return TaskResult::createSkipped ($ this , $ context );
75
78
}
@@ -116,4 +119,14 @@ private function hasLocalRepository(SplFileInfo $composerFile): bool
116
119
117
120
return false ;
118
121
}
122
+
123
+ /**
124
+ * Verbatim copy from \Composer\Factory::getLockFile.
125
+ */
126
+ private static function getLockFile (string $ composerFile ): string
127
+ {
128
+ return 'json ' === pathinfo ($ composerFile , PATHINFO_EXTENSION )
129
+ ? substr ($ composerFile , 0 , -4 ) . 'lock '
130
+ : $ composerFile . '.lock ' ;
131
+ }
119
132
}
Original file line number Diff line number Diff line change @@ -195,6 +195,15 @@ public function provideExternalTaskRuns(): iterable
195
195
'./composer.json ' ,
196
196
]
197
197
];
198
+ yield 'lock-only ' => [
199
+ [],
200
+ $ this ->mockContext (RunContext::class, ['composer.lock ' ]),
201
+ 'composer ' ,
202
+ [
203
+ 'validate ' ,
204
+ './composer.json ' ,
205
+ ]
206
+ ];
198
207
yield 'no-check-all ' => [
199
208
[
200
209
'no_check_all ' => true ,
You can’t perform that action at this time.
0 commit comments