Merge pull request '#6202 myt watcher' (!2377) from 6202-mytWatcher into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2377 Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
commit
03a8dafe47
|
@ -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;
|
|
@ -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`;
|
||||
|
|
|
@ -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": [
|
||||
|
|
Loading…
Reference in New Issue