* Processes single file. * * @param {String} path * @returns {Promise}
(path)
| 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. |
no test coverage detected