7430_devToTest #2490
|
@ -0,0 +1,31 @@
|
||||||
|
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;
|
|
@ -6,6 +6,7 @@ const log = require('fancy-log');
|
||||||
const Myt = require('@verdnatura/myt/myt');
|
const Myt = require('@verdnatura/myt/myt');
|
||||||
const Run = require('@verdnatura/myt/myt-run');
|
const Run = require('@verdnatura/myt/myt-run');
|
||||||
const Start = require('@verdnatura/myt/myt-start');
|
const Start = require('@verdnatura/myt/myt-start');
|
||||||
|
const watchDatabaseChanges = require('./db/dbWatcher');
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
|
|
||||||
|
@ -245,6 +246,7 @@ routes.description = 'Merges all module routes file into one file';
|
||||||
function watch(done) {
|
function watch(done) {
|
||||||
gulp.watch(routeFiles, gulp.series(routes));
|
gulp.watch(routeFiles, gulp.series(routes));
|
||||||
gulp.watch(localeFiles, gulp.series(locales));
|
gulp.watch(localeFiles, gulp.series(locales));
|
||||||
|
watchDatabaseChanges();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
watch.description = `Watches for changes in routes and locale files`;
|
watch.description = `Watches for changes in routes and locale files`;
|
||||||
|
|
|
@ -113,7 +113,8 @@
|
||||||
"test:e2e": "node e2e/tests.js",
|
"test:e2e": "node e2e/tests.js",
|
||||||
"test:front": "jest --watch",
|
"test:front": "jest --watch",
|
||||||
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
|
"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": {
|
"jest": {
|
||||||
"projects": [
|
"projects": [
|
||||||
|
|
Loading…
Reference in New Issue