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

23 lines
566 B
JavaScript
Raw Normal View History

2019-08-03 10:19:56 +08:00
const chokidar = require('chokidar')
const ws = require('./server')
const fs = require("fs")
2019-08-03 02:03:56 +08:00
require('shelljs/global')
exec('npm run dev', () => {
})
2019-08-03 10:19:56 +08:00
ws.listen(7777)
chokidar.watch(process.cwd() + "/bundle", {
2019-08-03 02:03:56 +08:00
ignored: /(^|[\/\\])\../,
}).on('all', (event, path) => {
2019-08-03 10:19:56 +08:00
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)
})
})
}
2019-08-03 02:03:56 +08:00
});