mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/* eslint-env node */
|
|
/* eslint import/no-unresolved:0, no-console:0 */
|
|
import {spawn} from 'node:child_process';
|
|
import {join} from 'node:path';
|
|
import {stderr, stdout} from 'node:process';
|
|
|
|
import sane from 'sane';
|
|
|
|
const watcherPy = sane(join(__dirname, '../src/sentry'));
|
|
const watcherJson = sane(join(__dirname, '../api-docs'));
|
|
|
|
const watchers = [watcherPy, watcherJson];
|
|
|
|
let isCurrentlyRunning = false;
|
|
|
|
const makeApiDocsCommand = function () {
|
|
if (isCurrentlyRunning) {
|
|
console.log('already rebuilding docs');
|
|
return;
|
|
}
|
|
console.log('rebuilding OpenAPI schema...');
|
|
isCurrentlyRunning = true;
|
|
const buildCommand = spawn('make', ['-C', '../', 'build-api-docs']);
|
|
|
|
buildCommand.stdout.on('data', function (data) {
|
|
stdout.write(data.toString());
|
|
});
|
|
|
|
buildCommand.stderr.on('data', function (data) {
|
|
stderr.write('stderr: ' + data.toString());
|
|
});
|
|
|
|
buildCommand.on('exit', function () {
|
|
isCurrentlyRunning = false;
|
|
});
|
|
};
|
|
|
|
for (const w of watchers) {
|
|
w.on('change', makeApiDocsCommand);
|
|
w.on('add', makeApiDocsCommand);
|
|
w.on('delete', makeApiDocsCommand);
|
|
}
|
|
console.log('rebuilding OpenAPI schema on changes');
|