2017-06-05 26 views
1

我遇到一個問題,其中jekyll serve在更改文件時陷入無限循環。爲了調試這個,我想知道哪個文件導致了再生,在Regenerating: 1 file(s) changed at ...輸出中列出。如何讓`jekyll serve --watch`列出哪個文件被重新生成?

例如,這裏是我的輸出:

[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. 

我怎麼知道哪些文件觸發了再生?

+0

目前不可能開箱即可調試哪個文件觸發了再生。如果您熟悉Ruby並熟悉編輯寶石,那麼我在'jekyll-watch'回購庫中有一個[patch](https://github.com/jekyll/jekyll-watch/pull/42/files)將指出哪個文件正好觸發了regen。 – ashmaroli

回答

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行添加打印或調試器語句以獲取有關導致生成的文件的信息。

相關問題