| 143 | } |
| 144 | |
| 145 | function processFiles(files) { |
| 146 | const promises = files.map(file => { |
| 147 | return comb.processPath(file); |
| 148 | }); |
| 149 | |
| 150 | Promise.all(promises).catch(error => { |
| 151 | process.stderr.write(error.stack); |
| 152 | process.exit(1); |
| 153 | }).then(c => { |
| 154 | c = [].concat.apply([], c); |
| 155 | var tbchanged = c.filter(isChanged => { |
| 156 | return isChanged !== undefined; |
| 157 | }).reduce((a, b) => { |
| 158 | return a + b; |
| 159 | }, 0); |
| 160 | |
| 161 | var changed = options.lint ? 0 : tbchanged; |
| 162 | |
| 163 | if (options.verbose) { |
| 164 | let message = [ |
| 165 | `${c.length} file${c.length === 1 ? '' : 's'} processed`, |
| 166 | `${changed} file${changed === 1 ? '' : 's'} fixed`, |
| 167 | '' |
| 168 | ].join(os.EOL); |
| 169 | process.stdout.write(message); |
| 170 | } |
| 171 | |
| 172 | if (options.lint && tbchanged) { |
| 173 | process.exit(1); |
| 174 | } |
| 175 | |
| 176 | process.exit(0); |
| 177 | }); |
| 178 | } |
| 179 | |
| 180 | function processSTDIN() { |
| 181 | getInputData.then(processInputData); |