| 208 | const tfProc = require('child_process').spawn(command, args, options); |
| 209 | tfProc.stdout.on('data', (buf) => { |
| 210 | const parse = (line) => { |
| 211 | if (line === '') return; |
| 212 | try { |
| 213 | const { '@level': level, '@message': message } = JSON.parse(line); |
| 214 | if (level === 'error') { |
| 215 | logger.error(`terraform error: ${message}`); |
| 216 | } else { |
| 217 | logger.info(message); |
| 218 | } |
| 219 | } catch (err) { |
| 220 | logger.info(line); |
| 221 | } |
| 222 | }; |
| 223 | buf.toString('utf8').split('\n').forEach(parse); |
| 224 | }); |
| 225 | tfProc.stderr.on('data', (buf) => { |