1
0
Fork 0
mirror of https://github.com/archtechx/airwire.git synced 2025-12-12 02:34:04 +00:00
airwire/resources/js/AirwireWatcher.js
Samuel Štancl d26fa93f1e initial
2021-05-20 20:15:55 +02:00

23 lines
589 B
JavaScript

const chokidar = require('chokidar');
const exec = require('child_process').exec;
class AirwireWatcher {
constructor(files = 'app/**/*.php') {
this.files = files;
}
apply(compiler) {
compiler.hooks.afterEnvironment.tap('AirwireWatcher', () => {
chokidar
.watch(this.files, { usePolling: false, persistent: true })
.on('change', this.fire);
});
}
fire() {
exec('php artisan airwire:generate');
console.log('Rebuilding Airwire definitions');
}
}
module.exports = AirwireWatcher;