Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable watch to prevent race condition between threads calling site.process #320

Merged
merged 23 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fd83a67
When updating a document or page, read item by itself
parkr Mar 9, 2017
1203e14
Use ensure_* helper methods and use this more robust method as a fall…
parkr Mar 9, 2017
9e7b78d
Use accurate method names; add the || for the page server back.
parkr Mar 11, 2017
efd6ede
Merge branch 'master' into prevent-race-condition-on-change
mertkahyaoglu Mar 11, 2017
4ce5082
centralize path manipulation methods in server.rb
benbalter Mar 13, 2017
c43c34e
slightly less abstraction
benbalter Mar 13, 2017
0c170bd
DRY up removing the site source
benbalter Mar 13, 2017
82aba50
move path helper methods to its own module
benbalter Mar 13, 2017
a573bb5
correct rubocop offenses;
benbalter Mar 13, 2017
87f8e2b
centralize file manipulation methods in file helper
benbalter Mar 14, 2017
9514901
autoload ALL THE THINGS!
benbalter Mar 14, 2017
2bf85ae
add some missing tests
benbalter Mar 14, 2017
3652c41
use FileHelper and PathHelper for DataFile methods
benbalter Mar 14, 2017
f4d94ab
add entries url to collection hash
benbalter Mar 14, 2017
1d5a49b
directory_path should be private
benbalter Mar 14, 2017
5a87555
actually, actually disable watch
benbalter Mar 14, 2017
e26934f
Use @ashmaroli's approach to monkey patching the build command to dis…
benbalter Mar 15, 2017
7d086f2
stop server before starting just in case
benbalter Mar 15, 2017
c8fab6c
-f, not -9
benbalter Mar 15, 2017
e1af381
Merge branch 'master' into prevent-race-condition-on-change
benbalter Mar 15, 2017
28c4f9c
revert changes to lib/jekyll/commands/serve.rb
benbalter Mar 15, 2017
1f8c8c2
test --watch with this plugin
ashmaroli Mar 15, 2017
bce59f7
Merge pull request #324 from ashmaroli/test-watch-admin
benbalter Mar 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/jekyll-admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def self.site

# Monkey Patches
require_relative "./jekyll/commands/serve"
require_relative "./jekyll/commands/build"

[Jekyll::Page, Jekyll::Document, Jekyll::StaticFile, Jekyll::Collection].each do |klass|
klass.include JekyllAdmin::APIable
klass.include JekyllAdmin::URLable
Expand Down
14 changes: 14 additions & 0 deletions lib/jekyll/commands/build.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Jekyll
module Commands
class Build < Command
class << self
alias_method :original_build, :build

def build(site, options)
options["watch"] = false
original_build(site, options)
end
end
end
end
end
2 changes: 1 addition & 1 deletion script/test-server
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -e
script/branding

cd ./spec/fixtures/site || exit
RACK_ENV=development bundle exec jekyll serve --verbose
RACK_ENV=development bundle exec jekyll serve --verbose --watch
19 changes: 18 additions & 1 deletion spec/jekyll-admin/integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe "integration" do
let(:source) { fixture_path("site") }
let(:dest) { File.join(source, "_site") }
let(:args) { ["--detach", "--source", source, "--destination", dest] }
let(:args) { ["--detach", "--watch", "--source", source, "--destination", dest] }
let(:start_command) { %w(bundle exec jekyll serve).concat(args) }
let(:stop_command) { ["pkill", "-f", "jekyll"] }
let(:server) { "http://localhost:4000" }
Expand Down Expand Up @@ -44,4 +44,21 @@
expect(response.body).to match("collections_api")
end
end

context "watching" do
it "Jekyll isn't watching", :skip => Gem.win_platform? do
File.open(File.join(source, "page.md"), "a") do |f|
f.puts "peek-a-boo"
end
content = File.read(File.join(source, "page.md"))
output = File.read(File.join(dest, "page.html"))

expect(content).to include("peek-a-boo")
expect(output).not_to include("peek-a-boo")

File.open(File.join(source, "page.md"), "w+") do |f|
f.write "---\nfoo: bar\n---\n\n# Test Page\n"
end
end
end
end