Skip to content

Commit 6dd908b

Browse files
Merge pull request #320 from jekyll/prevent-race-condition-on-change
When updating a document or page, read item by itself
2 parents 2a9876c + bce59f7 commit 6dd908b

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

lib/jekyll-admin.rb

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def self.site
3939

4040
# Monkey Patches
4141
require_relative "./jekyll/commands/serve"
42+
require_relative "./jekyll/commands/build"
43+
4244
[Jekyll::Page, Jekyll::Document, Jekyll::StaticFile, Jekyll::Collection].each do |klass|
4345
klass.include JekyllAdmin::APIable
4446
klass.include JekyllAdmin::URLable

lib/jekyll/commands/build.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Jekyll
2+
module Commands
3+
class Build < Command
4+
class << self
5+
alias_method :original_build, :build
6+
7+
def build(site, options)
8+
options["watch"] = false
9+
original_build(site, options)
10+
end
11+
end
12+
end
13+
end
14+
end

script/test-server

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -e
55
script/branding
66

77
cd ./spec/fixtures/site || exit
8-
RACK_ENV=development bundle exec jekyll serve --verbose
8+
RACK_ENV=development bundle exec jekyll serve --verbose --watch

spec/jekyll-admin/integration_spec.rb

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe "integration" do
22
let(:source) { fixture_path("site") }
33
let(:dest) { File.join(source, "_site") }
4-
let(:args) { ["--detach", "--source", source, "--destination", dest] }
4+
let(:args) { ["--detach", "--watch", "--source", source, "--destination", dest] }
55
let(:start_command) { %w(bundle exec jekyll serve).concat(args) }
66
let(:stop_command) { ["pkill", "-f", "jekyll"] }
77
let(:server) { "http://localhost:4000" }
@@ -44,4 +44,21 @@
4444
expect(response.body).to match("collections_api")
4545
end
4646
end
47+
48+
context "watching" do
49+
it "Jekyll isn't watching", :skip => Gem.win_platform? do
50+
File.open(File.join(source, "page.md"), "a") do |f|
51+
f.puts "peek-a-boo"
52+
end
53+
content = File.read(File.join(source, "page.md"))
54+
output = File.read(File.join(dest, "page.html"))
55+
56+
expect(content).to include("peek-a-boo")
57+
expect(output).not_to include("peek-a-boo")
58+
59+
File.open(File.join(source, "page.md"), "w+") do |f|
60+
f.write "---\nfoo: bar\n---\n\n# Test Page\n"
61+
end
62+
end
63+
end
4764
end

0 commit comments

Comments
 (0)