@@ -76,18 +76,26 @@ public function attachFiles($inputPath, $outputPath)
76
76
}
77
77
}
78
78
79
+ /**
80
+ * @return File[]
81
+ */
82
+ public function getFiles ()
83
+ {
84
+ return $ this ->files ;
85
+ }
86
+
79
87
/**
80
88
* @return string[]
81
89
*/
82
- public function concatOutput ()
90
+ protected function concatOutput ()
83
91
{
84
92
$ outputMap = [];
85
93
foreach ($ this ->files as $ file ) {
86
94
if (!isset ($ outputMap [$ file ->getOutputPath ()])) {
87
- $ outputMap [$ file ->getOutputPath ()] = $ file ->getParsedContent ();
88
- } else {
89
- $ outputMap [$ file ->getOutputPath ()] .= $ file ->getParsedContent ();
95
+ $ outputMap [$ file ->getOutputPath ()] = '' ;
90
96
}
97
+
98
+ $ outputMap [$ file ->getOutputPath ()] .= $ file ->getParsedContent ();
91
99
}
92
100
93
101
return $ outputMap ;
@@ -117,26 +125,39 @@ public function saveOutput()
117
125
*/
118
126
public function processFiles ($ formatter )
119
127
{
128
+ $ this ->sass ->setFormatter ($ this ->getFormatterClass ($ formatter ));
129
+ $ this ->io ->write ("<info>use ' {$ formatter }' formatting</info> " );
130
+
120
131
foreach ($ this ->files as $ file ) {
121
132
$ this ->io ->write ("<info>processing</info>: {$ file ->getSourcePath ()}" );
122
133
$ file ->setSourceContentFromSourcePath ();
123
134
124
- switch ($ file ->getType ()) {
125
- case File::TYPE_COMPASS :
126
- case File::TYPE_SCSS :
127
- case File::TYPE_SASS :
128
- $ this ->sass ->setFormatter ($ this ->getFormatterClass ($ formatter ));
129
- $ content = $ this ->sass ->compile ($ file ->getSourceContent ());
130
- break ;
131
- case File::TYPE_LESS :
132
- $ content = $ this ->less ->compile ($ file ->getSourceContent ());
133
- break ;
134
- default :
135
- throw new CompilerException ('unknown compiler ' );
135
+ try {
136
+ $ this ->processFile ($ file );
137
+ } catch (CompilerException $ e ) {
138
+ $ this ->io ->writeError ("<error>failed to process: {$ file ->getSourcePath ()}</error> " );
136
139
}
140
+ }
141
+ }
137
142
138
- $ file ->setParsedContent ($ content );
143
+ /**
144
+ * @param File $file
145
+ *
146
+ * @return File
147
+ * @throws CompilerException
148
+ */
149
+ public function processFile (File $ file )
150
+ {
151
+ switch ($ file ->getType ()) {
152
+ case File::TYPE_COMPASS :
153
+ case File::TYPE_SCSS :
154
+ case File::TYPE_SASS :
155
+ return $ file ->setParsedContent ($ this ->sass ->compile ($ file ->getSourceContent ()));
156
+ case File::TYPE_LESS :
157
+ return $ file ->setParsedContent ($ this ->less ->compile ($ file ->getSourceContent ()));
139
158
}
159
+
160
+ throw new CompilerException ('unknown compiler ' );
140
161
}
141
162
142
163
/**
0 commit comments