| 14 | let isCurrentlyRunning = false; |
| 15 | |
| 16 | const makeApiDocsCommand = function () { |
| 17 | if (isCurrentlyRunning) { |
| 18 | console.log('already rebuilding docs'); |
| 19 | return; |
| 20 | } |
| 21 | console.log('rebuilding OpenAPI schema...'); |
| 22 | isCurrentlyRunning = true; |
| 23 | const buildCommand = spawn('make', ['-C', '../', 'build-api-docs']); |
| 24 | |
| 25 | buildCommand.stdout.on('data', function (data) { |
| 26 | stdout.write(data.toString()); |
| 27 | }); |
| 28 | |
| 29 | buildCommand.stderr.on('data', function (data) { |
| 30 | stderr.write('stderr: ' + data.toString()); |
| 31 | }); |
| 32 | |
| 33 | buildCommand.on('exit', function () { |
| 34 | isCurrentlyRunning = false; |
| 35 | }); |
| 36 | }; |
| 37 | |
| 38 | for (const w of watchers) { |
| 39 | w.on('change', makeApiDocsCommand); |