惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
J
Java Code Geeks
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
MongoDB | Blog
MongoDB | Blog
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
雷峰网
雷峰网
D
DataBreaches.Net
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta

Recent Commits to jekyll:master

docs: Update Getform branding to Forminit (#10006) · jekyll/jekyll@541d8b2 fix(core): avoid mutating document data for fallback dates (#9981) · jekyll/jekyll@78aac81 docs: Add harvis to third-party deployment docs (#10009) · jekyll/jekyll@20ea323 build: soft deprecate old rubies (#10016) · jekyll/jekyll@6504236 build: update allowed cc types from the spec summary (#10017) · jekyll/jekyll@578d65b docs: remove the stale duplicate Code of Conduct page (#10010) · jekyll/jekyll@d2650e8 docs: add DeployHQ to third-party deployment providers (#9991) · jekyll/jekyll@7697d24 docs: update wsl installation procedure (#9968) · jekyll/jekyll@202df57 fix: Run release-please workflow only in jekyll/jekyll repo (#9969) · jekyll/jekyll@d68f76e feat!: Streamline the release process for Jekyll (#9760) · jekyll/jekyll@5cf05d7 Update history to reflect merge of #9960 [ci skip] · jekyll/jekyll@08c22ee Add GitCMS to resources docs (#9960) · jekyll/jekyll@3ed83f6 Update history to reflect merge of #9954 [ci skip] · jekyll/jekyll@ff0d4dd build: fix broken CI on newer rubies (#9954) · jekyll/jekyll@65d534a Update history to reflect merge of #9925 [ci skip] · jekyll/jekyll@baab7bf Allow configuring future metadata for individual collections (#9925) · jekyll/jekyll@f07d4f7 Update history to reflect merge of #9914 [ci skip] · jekyll/jekyll@d0cf179 Add .ruby-lsp to default excludes (#9914) · jekyll/jekyll@3c45d9e Update history to reflect merge of #9920 [ci skip] · jekyll/jekyll@26ec089 Add logger to Gemfile for Ruby 4.0 (#9920) · jekyll/jekyll@7e79e46 Update history to reflect merge of #9923 [ci skip] · jekyll/jekyll@b49aa9b Bump supported versions (#9923) · jekyll/jekyll@ebe567c Update history to reflect merge of #9897 [ci skip] · jekyll/jekyll@4d3db3a Update WDM (0.1.1 → 0.2.0) in the Windows docs (#9897) · jekyll/jekyll@6da6739 Update history to reflect merge of #9912 [ci skip] · jekyll/jekyll@161f654 docs: Update contributor badge in README to include avatar height and… · jekyll/jekyll@e1b5fd6 Update history to reflect merge of #9889 [ci skip] · jekyll/jekyll@2fe6977
fix: update clean command to take account of the keep_fil...
ianoxley · 2026-08-04 · via Recent Commits to jekyll:master
1+

# frozen_string_literal: true

2+3+

require "mercenary"

4+

require "helper"

5+

require "tmpdir"

6+7+

class TestCommandsClean < JekyllUnitTest

8+

context "cleaning destination" do

9+

setup do

10+

@merc = nil

11+

@cmd = Jekyll::Commands::Clean

12+

Mercenary.program(:jekyll) do |p|

13+

@merc = @cmd.init_with_program(

14+

p

15+

)

16+

end

17+18+

@temp_dir = Dir.mktmpdir("jekyll_clean_test")

19+

@destination = File.join(@temp_dir, "_site")

20+

Dir.mkdir(@destination) || flunk("Could not make directory #{@destination}")

21+

@standard_options = {

22+

"port" => 4000,

23+

"host" => "localhost",

24+

"baseurl" => "",

25+

"detach" => false,

26+

"source" => @temp_dir,

27+

"destination" => @destination,

28+

}

29+30+

simple_page = <<-HTML.gsub(%r!^\s*!, "")

31+

<!DOCTYPE HTML>

32+

<html lang="en-US">

33+

<head>

34+

<meta charset="UTF-8">

35+

<title>Hello World</title>

36+

</head>

37+

<body>

38+

<p>Hello! I am a simple web page.</p>

39+

</body>

40+

</html>

41+

HTML

42+43+

File.write(File.join(@destination, "hello.html"), simple_page)

44+45+

@site = instance_double(Jekyll::Site, :jekyll_site)

46+

allow(Jekyll::Site).to receive(:new).and_return(@site)

47+

end

48+49+

teardown do

50+

FileUtils.remove_entry_secure(@temp_dir, true)

51+

end

52+53+

should "call Site#cleanup" do

54+

expect(@site).to receive(:cleanup)

55+

@merc.execute(:clean, @standard_options)

56+

end

57+58+

context "with the keep_files option" do

59+

setup do

60+

@standard_options["keep_files"] = %w(keep)

61+

@keep_dir = File.join(@temp_dir, "_site/keep")

62+63+

keep_page = <<-HTML.gsub(%r!^\s*!, "")

64+

<!DOCTYPE HTML>

65+

<html lang="en-US">

66+

<head>

67+

<meta charset="UTF-8">

68+

<title>Page to Keep</title>

69+

</head>

70+

<body>

71+

<p>This page is to keep.</p>

72+

</body>

73+

</html>

74+

HTML

75+76+

Dir.mkdir(@keep_dir) || flunk("Could not make directory #{@keep_dir}")

77+

File.write(File.join(@keep_dir, "keep.html"), keep_page)

78+79+

allow(Jekyll::Site).to receive(:new).and_call_original

80+

end

81+82+

should "keep the specified files and directories" do

83+

@merc.execute(:clean, @standard_options)

84+

assert_path_exists(File.join(@keep_dir, "keep.html"))

85+

end

86+

end

87+

end

88+

end