ui-watcher.js 456 B

123456789101112131415
  1. const fse = require('fs-extra')
  2. const chokidar = require('chokidar')
  3. const watchDirs = ['../ui-domain', '../ui-utils', '../ui-components']
  4. chokidar.watch(watchDirs).on('all', (event, path) => {
  5. const dest = './node_modules' + path.split('..')[1]
  6. if (event.indexOf('unlink') !== -1) {
  7. fse.remove(dest)
  8. } else {
  9. fse.copySync(path, dest)
  10. }
  11. }).on('ready', () => {
  12. console.log('目录:' + watchDirs.join(' | ') + ' 正在监听中...')
  13. })