MCPcopy
hub / github.com/csscomb/csscomb.js / processFile

Method processFile

src/core.js:183–214  ·  view source on GitHub ↗

* Processes single file. * * @param {String} path * @returns {Promise}

(path)

Source from the content-addressed store, hash-verified

181 * @returns {Promise}
182 */
183 processFile(path) {
184 let that = this;
185
186 if (!this._shouldProcessFile(path)) return;
187
188 return new Promise(resolve => {
189 vfs.read(path, 'utf8').then(function(data) {
190 let syntax = that._extractSyntax(path);
191 that.processString(data, {
192 syntax: syntax,
193 filename: path
194 }).then(function(processedData) {
195 if (data === processedData) {
196 if (that.verbose) console.log(' ', path);
197 resolve(0);
198 return;
199 }
200
201 let tick = that.lint ? '!' : '✓';
202 if (that.lint) {
203 if (that.verbose) console.log(tick, path);
204 resolve(1);
205 } else {
206 return vfs.write(path, processedData, 'utf8').then(function() {
207 if (that.verbose) console.log(tick, path);
208 resolve(1);
209 });
210 }
211 });
212 });
213 });
214 }
215
216 /**
217 * Processes directory or file.

Callers 2

processDirectoryMethod · 0.80
processPathMethod · 0.80

Calls 3

_shouldProcessFileMethod · 0.95
_extractSyntaxMethod · 0.80
processStringMethod · 0.80

Tested by

no test coverage detected