如何使`jekyll serve --watch`列表重新生成哪个文件?

时间:2017-06-05 02:44:12

标签: jekyll

我遇到了一个问题,当文件发生变化时,jekyll serve会在无限循环中被捕获。为了调试这个,我想知道在Regenerating: 1 file(s) changed at ...输出中列出了导致重新生成的文件。

例如,这是我的输出:

[my-pc]/home/.../websites/openseattle.github.io$ bundle exec jekyll serve
Configuration file: /home/lucas/projects/websites/openseattle.github.io/_config.yml
            Source: /home/lucas/projects/websites/openseattle.github.io
       Destination: /home/lucas/projects/websites/openseattle.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
                    done in 0.616 seconds.
 Auto-regeneration: enabled for '/home/lucas/projects/websites/openseattle.github.io'
Configuration file: /home/lucas/projects/websites/openseattle.github.io/_config.yml
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.
      Regenerating: 2 file(s) changed at 2017-06-04 19:40:58 ...done in 0.485150987 seconds.
      Regenerating: 1 file(s) changed at 2017-06-04 19:40:59 ...done in 0.45860538 seconds.
      Regenerating: 1 file(s) changed at 2017-06-04 19:41:00 ...done in 0.482768408 seconds.
      Regenerating: 1 file(s) changed at 2017-06-04 19:41:00 ...done in 0.46793245 seconds.
      Regenerating: 1 file(s) changed at 2017-06-04 19:41:01 ...done in 0.466628054 seconds.

我怎么知道哪个文件触发了再生?

1 个答案:

答案 0 :(得分:0)

我找到了一种方法来做到这一点,但我希望有一种更简单的方法(如上面评论中的@ashmaroli所述):

运行bundle show jekyll-watch以找出jekyll-watch模块的位置。

您应该找到名为watcher.rb的文件。它应该如下所示:https://github.com/jekyll/jekyll-watch/blob/master/lib/jekyll/watcher.rb#L56

然后在第55-56行添加一个打印或调试器语句,以获取有关导致生成的文件的信息。