watch()

in websites/mini-program/scripts/watchMd.js [38:60]


  watch() {
    this.watcher.on('change', (changePath) => {
      console.log(
        chalk.blue(`bui markdown file changed! change path: ${changePath}`),
      );
      const scriptPath = path.resolve(
        process.cwd(),
        '../../scripts/mini-program-site/generateMiniFiles.js',
      );
      shelljs.exec(`node ${scriptPath}`, (code, stdout, stderr) => {
        if (code === 0) {
          console.log(
            chalk.green(
              `✅  小程序代码生成成功!`,
              dayjs().format('YYYY-MM-DD hh:mm:ss'),
            ),
          );
        } else {
          console.log(chalk.red(`❌  小程序代码生成失败!`, stderr));
        }
      });
    });
  }