This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-cli/scripts/watcher.js
2019-08-03 10:19:56 +08:00

23 lines
566 B
JavaScript

const chokidar = require('chokidar')
const ws = require('./server')
const fs = require("fs")
require('shelljs/global')
exec('npm run dev', () => {
})
ws.listen(7777)
chokidar.watch(process.cwd() + "/bundle", {
ignored: /(^|[\/\\])\../,
}).on('all', (event, path) => {
console.log('path is ', path)
if (event === 'add' || event === 'change') {
fs.readFile(path, 'utf-8', (error, data) => {
console.log('send data ', data)
ws.connections.forEach(e => {
e.sendText(data)
})
})
}
});