7430_devToTest #2490

Merged
alexm merged 306 commits from 7430_devToTest into test 2024-05-21 09:15:04 +00:00
3 changed files with 28 additions and 1 deletions
Showing only changes of commit 03a8dafe47 - Show all commits

24
db/dbWatcher.js Normal file
View File

@ -0,0 +1,24 @@
const fs = require('fs');
const {spawn} = require('child_process');
function watchDatabaseChanges() {
console.log('Watching for changes in db/routines and db/versions');
fs.watch('db', {recursive: true}, (eventType, filename) => {
if (filename.endsWith('.sql')) {
let command;
if (filename.startsWith('routines')) command = 'push';
else if (filename.startsWith('versions')) command = 'run';
if (command) {
const process = spawn('myt', [command]);
process.stdout.on('data', data => console.log(data.toString()));
process.stderr.on('data', data => console.error(`stderr: ${data}`));
process.on('error', error => console.error(`error: ${error.message}`));
process.on('close', () => console.log('Watching for changes in db/routines and db/versions'));
}
}
});
}
if (require.main === module) watchDatabaseChanges();
module.exports = watchDatabaseChanges;

View File

@ -6,6 +6,7 @@ const log = require('fancy-log');
const Myt = require('@verdnatura/myt/myt');
const Run = require('@verdnatura/myt/myt-run');
const Start = require('@verdnatura/myt/myt-start');
const watchDatabaseChanges = require('./db/dbWatcher');
// Configuration
@ -245,6 +246,7 @@ routes.description = 'Merges all module routes file into one file';
function watch(done) {
gulp.watch(routeFiles, gulp.series(routes));
gulp.watch(localeFiles, gulp.series(locales));
watchDatabaseChanges();
done();
}
watch.description = `Watches for changes in routes and locale files`;

View File

@ -113,7 +113,8 @@
"test:e2e": "node e2e/tests.js",
"test:front": "jest --watch",
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
"lint": "eslint ./ --cache --ignore-pattern .gitignore"
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
"watch:db": "node ./db/dbWatcher.js"
},
"jest": {
"projects": [