watcher.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. var fs = require('fs');
  2. var { exec } = require('child_process');
  3. var twiceFix = false;
  4. function compileSASS(event, fname) {
  5. console.log(`${fname} as changed`);
  6. if(event == 'change' && twiceFix) {
  7. twiceFix = false;
  8. exec('sass ui/css/omlink.scss:ui/css/omlink.css', (error, out, err) => {
  9. console.log('------------------------------ compileSASS() ------------------------------');
  10. if(error) {
  11. console.log(error);
  12. return;
  13. }
  14. exec('npm run build dimatec');
  15. });
  16. }
  17. twiceFix = true;
  18. }
  19. console.log('Adding watcher for ui/css/omlink.scss');
  20. fs.watch('ui/css/omlink.scss', function(event, fname) {
  21. compileSASS(event, fname);
  22. });
  23. console.log('Adding watcher for ui/customizations/dimatec.scss');
  24. fs.watch('ui/customizations/dimatec.scss', function(event, fname) {
  25. compileSASS(event, fname);
  26. });
  27. console.log('Adding watcher for ui/customizations/lamborghini.scss');
  28. fs.watch('ui/customizations/lamborghini.scss', function(event, fname) {
  29. compileSASS(event, fname);
  30. });