template.js 394 B

12345678910111213141516
  1. const path = require('path');
  2. const templates = path.resolve(process.cwd(), './examples/pages/template');
  3. const chokidar = require('chokidar');
  4. let watcher = chokidar.watch([templates]);
  5. watcher.on('ready', function() {
  6. watcher
  7. .on('change', function() {
  8. exec('npm run i18n');
  9. });
  10. });
  11. function exec(cmd) {
  12. return require('child_process').execSync(cmd).toString().trim();
  13. }