fix(cleanup): Stop deleting files from destination
This commit is contained in:
		
							parent
							
								
									1caeb018cf
								
							
						
					
					
						commit
						112dc9bd18
					
				| @ -73,9 +73,13 @@ module Jekyll | |||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     # A Jekyll::Site subclass that overrides #write from the parent class to |     # A Jekyll::Site subclass that overrides #write from the parent class to | ||||||
|     # create JSON records out of rendered documents and push those records |     # create JSON records out of rendered documents and push those records to | ||||||
|     # to Algolia instead of writing files to disk. |     # Algolia instead of writing files to disk. | ||||||
|     class Site < Jekyll::Site |     class Site < Jekyll::Site | ||||||
|  |       # We make the cleanup method a noop, otherwise it will remove excluded | ||||||
|  |       # files from destination | ||||||
|  |       def cleanup; end | ||||||
|  | 
 | ||||||
|       def write |       def write | ||||||
|         records = [] |         records = [] | ||||||
|         files = [] |         files = [] | ||||||
|  | |||||||
| @ -65,6 +65,20 @@ describe(Jekyll::Algolia) do | |||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |   describe 'overriding Jekyll::Site#cleanup' do | ||||||
|  |     # Given | ||||||
|  |     let(:configuration) { Jekyll.configuration } | ||||||
|  |     let(:jekyll_site) { Jekyll::Site.new(configuration) } | ||||||
|  |     let(:algolia_site) { Jekyll::Algolia::Site.new(configuration) } | ||||||
|  |     let!(:initial_method) { jekyll_site.method(:cleanup).source_location } | ||||||
|  |     let!(:overridden_method) { algolia_site.method(:cleanup).source_location } | ||||||
|  | 
 | ||||||
|  |     # Then | ||||||
|  |     it 'should change the initial .cleanup method' do | ||||||
|  |       expect(overridden_method).to_not eq initial_method | ||||||
|  |     end | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|   describe '.run (mocked build)' do |   describe '.run (mocked build)' do | ||||||
|     # Prevent the whole process to stop if Algolia config is not available |     # Prevent the whole process to stop if Algolia config is not available | ||||||
|     before do |     before do | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user