@@ -24,6 +24,8 @@ trait CommandInitializerTrait
24
24
private $ io ;
25
25
/** @var OutputInterface */
26
26
private $ output ;
27
+ /** @var InputInterface */
28
+ private $ input ;
27
29
/** @var Builder */
28
30
private $ builder ;
29
31
/** @var Filesystem */
@@ -40,14 +42,15 @@ trait CommandInitializerTrait
40
42
private function doInitialize (InputInterface $ input , OutputInterface $ output , string $ sourceDir , string $ outputDir )
41
43
{
42
44
$ this ->io = new SymfonyStyle ($ input , $ output );
45
+ $ this ->input = $ input ;
43
46
$ this ->output = $ output ;
44
47
45
48
$ this ->buildContext ->initializeRuntimeConfig (
46
49
$ sourceDir ,
47
50
$ this ->initializeHtmlOutputDir ($ this ->filesystem , $ outputDir ),
48
51
$ this ->initializeJsonOutputDir ($ outputDir ),
49
52
$ this ->initializeParseSubPath ($ input , $ sourceDir ),
50
- ( bool ) $ input -> getOption ( ' disable-cache ' )
53
+ $ this -> isCacheDisabled ( )
51
54
);
52
55
53
56
$ this ->builder = new Builder (
@@ -71,7 +74,12 @@ private function initializeSourceDir(InputInterface $input, Filesystem $filesyst
71
74
72
75
private function initializeHtmlOutputDir (Filesystem $ filesystem , string $ path ): string
73
76
{
74
- return rtrim ($ this ->getRealAbsolutePath ($ path , $ filesystem ), '/ ' );
77
+ $ htmlOutputDir = rtrim ($ this ->getRealAbsolutePath ($ path , $ filesystem ), '/ ' );
78
+ if ($ this ->isCacheDisabled () && $ filesystem ->exists ($ htmlOutputDir )) {
79
+ $ filesystem ->remove ($ htmlOutputDir );
80
+ }
81
+
82
+ return $ htmlOutputDir ;
75
83
}
76
84
77
85
private function initializeParseSubPath (InputInterface $ input , string $ sourceDir ): string
@@ -98,7 +106,7 @@ private function initializeParseSubPath(InputInterface $input, string $sourceDir
98
106
private function initializeJsonOutputDir (string $ outputDir ): string
99
107
{
100
108
$ jsonOutputDir = $ this ->getRealAbsolutePath ($ outputDir .'/json ' , $ this ->filesystem );
101
- if ($ this ->filesystem ->exists ($ jsonOutputDir )) {
109
+ if ($ this ->isCacheDisabled () && $ this -> filesystem ->exists ($ jsonOutputDir )) {
102
110
$ this ->filesystem ->remove ($ jsonOutputDir );
103
111
}
104
112
@@ -144,6 +152,11 @@ private function startBuild()
144
152
);
145
153
}
146
154
155
+ private function isCacheDisabled (): bool
156
+ {
157
+ return (bool ) $ this ->input ->getOption ('disable-cache ' );
158
+ }
159
+
147
160
public function postParseDocument (PostParseDocumentEvent $ postParseDocumentEvent ): void
148
161
{
149
162
$ file = $ postParseDocumentEvent ->getDocumentNode ()->getEnvironment ()->getCurrentFileName ();
0 commit comments