jekyll-minibundle 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +35 -25
- data/Rakefile +6 -6
- data/jekyll-minibundle.gemspec +11 -11
- data/lib/jekyll/minibundle/asset_bundle.rb +19 -16
- data/lib/jekyll/minibundle/asset_file_operations.rb +3 -3
- data/lib/jekyll/minibundle/asset_file_paths.rb +2 -6
- data/lib/jekyll/minibundle/asset_file_registry.rb +28 -30
- data/lib/jekyll/minibundle/asset_stamp.rb +1 -1
- data/lib/jekyll/minibundle/asset_tag_markup.rb +16 -14
- data/lib/jekyll/minibundle/bundle_file.rb +10 -9
- data/lib/jekyll/minibundle/development_file.rb +6 -6
- data/lib/jekyll/minibundle/development_file_collection.rb +6 -6
- data/lib/jekyll/minibundle/environment.rb +10 -8
- data/lib/jekyll/minibundle/mini_bundle_block.rb +4 -4
- data/lib/jekyll/minibundle/mini_stamp_tag.rb +2 -2
- data/lib/jekyll/minibundle/stamp_file.rb +8 -7
- data/lib/jekyll/minibundle/version.rb +1 -1
- data/test/fixture/site/_bin/with_count +1 -1
- data/test/integration/minibundle_development_mode_test.rb +62 -40
- data/test/integration/minibundle_production_mode_test.rb +78 -70
- data/test/integration/ministamp_test.rb +23 -23
- data/test/integration/static_files_as_asset_sources_test.rb +11 -11
- data/test/support/fixture_config.rb +4 -4
- data/test/support/test_case.rb +18 -14
- data/test/unit/asset_bundle_test.rb +4 -4
- data/test/unit/asset_file_registry_test.rb +7 -7
- data/test/unit/asset_tag_markup_test.rb +1 -1
- data/test/unit/bundle_file_test.rb +43 -33
- data/test/unit/development_file_collection_test.rb +44 -0
- data/test/unit/stamp_file_test.rb +30 -18
- metadata +26 -24
@@ -6,33 +6,33 @@ module Jekyll::Minibundle::Test
|
|
6
6
|
include FixtureConfig
|
7
7
|
|
8
8
|
def test_asset_destination_path_has_no_stamp_in_development_mode
|
9
|
-
with_precompiled_site
|
9
|
+
with_precompiled_site(:development) do
|
10
10
|
assert_equal STAMP_DESTINATION_PATH, find_css_path_from_index
|
11
11
|
assert File.exists?(destination_path(STAMP_DESTINATION_PATH))
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_asset_destination_path_has_stamp_in_production_mode
|
16
|
-
with_precompiled_site
|
16
|
+
with_precompiled_site(:production) do
|
17
17
|
assert_equal STAMP_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
18
18
|
assert File.exists?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_contents_of_asset_destination_are_equal_to_source
|
23
|
-
with_precompiled_site
|
24
|
-
source_contents = File.read
|
25
|
-
destination_contents = File.read
|
23
|
+
with_precompiled_site(:production) do
|
24
|
+
source_contents = File.read(site_fixture_path(STAMP_SOURCE_PATH))
|
25
|
+
destination_contents = File.read(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
26
26
|
assert_equal source_contents, destination_contents
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_changing_asset_source_rewrites_destination
|
31
31
|
with_site do
|
32
|
-
generate_site
|
33
|
-
org_mtime = mtime_of
|
34
|
-
ensure_file_mtime_changes { File.write
|
35
|
-
generate_site
|
32
|
+
generate_site(:production)
|
33
|
+
org_mtime = mtime_of(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
34
|
+
ensure_file_mtime_changes { File.write(source_path(STAMP_SOURCE_PATH), 'h1 {}') }
|
35
|
+
generate_site(:production, clear_cache: false)
|
36
36
|
|
37
37
|
refute File.exists?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
38
38
|
|
@@ -46,11 +46,11 @@ module Jekyll::Minibundle::Test
|
|
46
46
|
|
47
47
|
def test_touching_asset_source_rewrites_destination
|
48
48
|
with_site do
|
49
|
-
generate_site
|
49
|
+
generate_site(:production)
|
50
50
|
destination = STAMP_DESTINATION_FINGERPRINT_PATH
|
51
|
-
org_mtime = mtime_of
|
52
|
-
ensure_file_mtime_changes { FileUtils.touch
|
53
|
-
generate_site
|
51
|
+
org_mtime = mtime_of(destination_path(destination))
|
52
|
+
ensure_file_mtime_changes { FileUtils.touch(source_path(STAMP_SOURCE_PATH)) }
|
53
|
+
generate_site(:production, clear_cache: false)
|
54
54
|
|
55
55
|
assert_equal destination, find_css_path_from_index
|
56
56
|
assert File.exists?(destination_path(destination))
|
@@ -60,14 +60,14 @@ module Jekyll::Minibundle::Test
|
|
60
60
|
|
61
61
|
def test_supports_relative_and_absolute_destination_paths
|
62
62
|
with_site do
|
63
|
-
generate_site
|
64
|
-
expected_path = destination_path
|
63
|
+
generate_site(:production)
|
64
|
+
expected_path = destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)
|
65
65
|
|
66
66
|
assert File.exists?(expected_path)
|
67
67
|
assert_equal STAMP_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
68
68
|
|
69
69
|
find_and_gsub_in_file(source_path('_layouts/default.html'), %r{assets/screen.css}, '/\0')
|
70
|
-
generate_site
|
70
|
+
generate_site(:production, clear_cache: false)
|
71
71
|
|
72
72
|
assert File.exists?(expected_path)
|
73
73
|
assert_equal "/#{STAMP_DESTINATION_FINGERPRINT_PATH}", find_css_path_from_index
|
@@ -76,16 +76,16 @@ module Jekyll::Minibundle::Test
|
|
76
76
|
|
77
77
|
def test_does_not_rewrite_destination_when_nonsource_files_change
|
78
78
|
with_site do
|
79
|
-
generate_site
|
80
|
-
expected_path = destination_path
|
81
|
-
org_mtime = mtime_of
|
82
|
-
ensure_file_mtime_changes { File.write
|
83
|
-
generate_site
|
79
|
+
generate_site(:production)
|
80
|
+
expected_path = destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)
|
81
|
+
org_mtime = mtime_of(expected_path)
|
82
|
+
ensure_file_mtime_changes { File.write(source_path(JS_BUNDLE_SOURCE_DIR, 'dependency.js'), '(function() {})()') }
|
83
|
+
generate_site(:production, clear_cache: false)
|
84
84
|
|
85
85
|
assert_equal org_mtime, mtime_of(expected_path)
|
86
86
|
|
87
|
-
ensure_file_mtime_changes { FileUtils.touch
|
88
|
-
generate_site
|
87
|
+
ensure_file_mtime_changes { FileUtils.touch('index.html') }
|
88
|
+
generate_site(:production, clear_cache: false)
|
89
89
|
|
90
90
|
assert_equal org_mtime, mtime_of(expected_path)
|
91
91
|
end
|
@@ -6,12 +6,12 @@ module Jekyll::Minibundle::Test
|
|
6
6
|
include FixtureConfig
|
7
7
|
|
8
8
|
def test_asset_and_static_files_with_same_destination_paths_can_coexist
|
9
|
-
with_precompiled_site
|
9
|
+
with_precompiled_site(:production) do
|
10
10
|
actual = Dir[destination_path('assets/site*.*')].sort
|
11
11
|
expected = [
|
12
12
|
destination_path('assets/site.css'),
|
13
|
-
destination_path(
|
14
|
-
destination_path(
|
13
|
+
destination_path(CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH),
|
14
|
+
destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH)
|
15
15
|
].sort
|
16
16
|
assert_equal expected, actual
|
17
17
|
end
|
@@ -21,9 +21,9 @@ module Jekyll::Minibundle::Test
|
|
21
21
|
define_method :"test_ministamp_allows_using_static_file_as_asset_source_in_#{env}_mode" do
|
22
22
|
with_site do
|
23
23
|
contents = 'h2 {}'
|
24
|
-
File.write
|
24
|
+
File.write(source_path('assets/shared.css'), contents)
|
25
25
|
find_and_gsub_in_file(source_path('_layouts/default.html'), 'ministamp _tmp/site.css', 'ministamp assets/shared.css')
|
26
|
-
generate_site
|
26
|
+
generate_site(env)
|
27
27
|
|
28
28
|
asset_files = Dir[destination_path('assets') + '/screen*.css']
|
29
29
|
|
@@ -38,10 +38,10 @@ module Jekyll::Minibundle::Test
|
|
38
38
|
with_site do
|
39
39
|
dep_contents = 'console.log("lol")'
|
40
40
|
app_contents = 'console.log("balal")'
|
41
|
-
File.write
|
42
|
-
File.write
|
41
|
+
File.write(source_path('assets/dependency.js'), dep_contents)
|
42
|
+
File.write(source_path('assets/app.js'), app_contents)
|
43
43
|
find_and_gsub_in_file(source_path('_layouts/default.html'), 'source_dir: _assets/scripts', 'source_dir: assets')
|
44
|
-
generate_site
|
44
|
+
generate_site(:development)
|
45
45
|
|
46
46
|
assert_equal dep_contents, File.read(destination_path('assets/dependency.js'))
|
47
47
|
assert_equal app_contents, File.read(destination_path('assets/app.js'))
|
@@ -53,10 +53,10 @@ module Jekyll::Minibundle::Test
|
|
53
53
|
dep_contents = 'console.log("lol")'
|
54
54
|
app_contents = 'console.log("balal")'
|
55
55
|
bundled_contents = "#{dep_contents};\n#{app_contents};\n"
|
56
|
-
File.write
|
57
|
-
File.write
|
56
|
+
File.write(source_path('assets/dependency.js'), dep_contents)
|
57
|
+
File.write(source_path('assets/app.js'), app_contents)
|
58
58
|
find_and_gsub_in_file(source_path('_layouts/default.html'), 'source_dir: _assets/scripts', 'source_dir: assets')
|
59
|
-
generate_site
|
59
|
+
generate_site(:production)
|
60
60
|
|
61
61
|
asset_files = Dir[destination_path('assets/site-*.js')]
|
62
62
|
|
@@ -4,12 +4,12 @@ module Jekyll::Minibundle::Test
|
|
4
4
|
STAMP_DESTINATION_PATH = 'assets/screen.css'
|
5
5
|
STAMP_DESTINATION_FINGERPRINT_PATH = 'assets/screen-d57c1404fe726e66d57128a1bd190cbb.css'
|
6
6
|
|
7
|
-
CSS_BUNDLE_DESTINATION_PATH = 'assets/site'
|
8
7
|
CSS_BUNDLE_SOURCE_DIR = '_assets/styles'
|
9
|
-
|
8
|
+
CSS_BUNDLE_DESTINATION_PATH = 'assets/site'
|
9
|
+
CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH = CSS_BUNDLE_DESTINATION_PATH + '-b2e0ecc1c100effc2c7353caad20c327.css'
|
10
10
|
|
11
|
-
JS_BUNDLE_DESTINATION_PATH = 'assets/site'
|
12
11
|
JS_BUNDLE_SOURCE_DIR = '_assets/scripts'
|
13
|
-
|
12
|
+
JS_BUNDLE_DESTINATION_PATH = 'assets/site'
|
13
|
+
JS_BUNDLE_DESTINATION_FINGERPRINT_PATH = JS_BUNDLE_DESTINATION_PATH + '-4782a1f67803038d4f8351051e67deb8.js'
|
14
14
|
end
|
15
15
|
end
|
data/test/support/test_case.rb
CHANGED
@@ -28,9 +28,9 @@ module Jekyll::Minibundle::Test
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def find_and_gsub_in_file(file, pattern, replacement)
|
31
|
-
old_content = File.read
|
32
|
-
new_content = old_content.gsub
|
33
|
-
File.write
|
31
|
+
old_content = File.read(file)
|
32
|
+
new_content = old_content.gsub(pattern, replacement)
|
33
|
+
File.write(file, new_content)
|
34
34
|
end
|
35
35
|
|
36
36
|
def mtime_of(path)
|
@@ -49,9 +49,9 @@ module Jekyll::Minibundle::Test
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def with_site(&block)
|
52
|
-
Dir.mktmpdir
|
53
|
-
Dir.chdir
|
54
|
-
_copy_fixture_site_dir
|
52
|
+
Dir.mktmpdir("jekyll-minibundle-test-site-") do |dir|
|
53
|
+
Dir.chdir(dir) do
|
54
|
+
_copy_fixture_site_dir(Dir.pwd)
|
55
55
|
yield dir
|
56
56
|
end
|
57
57
|
end
|
@@ -62,8 +62,8 @@ module Jekyll::Minibundle::Test
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def generate_site(mode, options = {})
|
65
|
-
with_env
|
66
|
-
_generate_site
|
65
|
+
with_env('JEKYLL_MINIBUNDLE_MODE' => mode.to_s) do
|
66
|
+
_generate_site(_get_site_generation_test_options(options))
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -77,13 +77,17 @@ module Jekyll::Minibundle::Test
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def get_cmd_count
|
80
|
-
File.
|
80
|
+
if File.exists?('count')
|
81
|
+
File.read('count').to_i
|
82
|
+
else
|
83
|
+
0
|
84
|
+
end
|
81
85
|
end
|
82
86
|
|
83
87
|
private
|
84
88
|
|
85
89
|
def _copy_fixture_site_dir(dir)
|
86
|
-
FileUtils.cp_r
|
90
|
+
FileUtils.cp_r(site_fixture_path('.'), dir)
|
87
91
|
end
|
88
92
|
|
89
93
|
@@_precompiled_site_dirs = {}
|
@@ -92,12 +96,12 @@ module Jekyll::Minibundle::Test
|
|
92
96
|
@@_precompiled_site_dirs[mode] ||= begin
|
93
97
|
dir = Dir.mktmpdir("jekyll-minibundle-test-precompiled-site-#{mode}-")
|
94
98
|
at_exit do
|
95
|
-
FileUtils.rm_rf
|
99
|
+
FileUtils.rm_rf(dir)
|
96
100
|
puts "\nCleaned precompiled site in #{mode} mode for tests: #{dir}"
|
97
101
|
end
|
98
102
|
Dir.chdir(dir) do
|
99
|
-
_copy_fixture_site_dir
|
100
|
-
generate_site
|
103
|
+
_copy_fixture_site_dir(Dir.pwd)
|
104
|
+
generate_site(mode)
|
101
105
|
end
|
102
106
|
dir
|
103
107
|
end
|
@@ -112,7 +116,7 @@ module Jekyll::Minibundle::Test
|
|
112
116
|
end
|
113
117
|
|
114
118
|
def _get_site_generation_test_options(options)
|
115
|
-
TestCase.site_generation_test_options.merge
|
119
|
+
TestCase.site_generation_test_options.merge(options)
|
116
120
|
end
|
117
121
|
|
118
122
|
def self.site_generation_test_options
|
@@ -5,7 +5,7 @@ module Jekyll::Minibundle::Test
|
|
5
5
|
class AssetBundleTest < TestCase
|
6
6
|
def test_raise_exception_if_bundle_command_fails
|
7
7
|
capture_io do
|
8
|
-
with_env
|
8
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => 'false') do
|
9
9
|
err = assert_raises(RuntimeError) { make_bundle }
|
10
10
|
assert_equal 'Bundling js assets failed with exit status 1, command: false', err.to_s
|
11
11
|
end
|
@@ -13,13 +13,13 @@ module Jekyll::Minibundle::Test
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_raise_exception_if_bundle_command_not_found
|
16
|
-
with_env
|
16
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => 'no-such-jekyll-minibundle-cmd') do
|
17
17
|
assert_raises(Errno::ENOENT) { make_bundle }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_raise_exception_if_bundle_command_not_configured
|
22
|
-
with_env
|
22
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => nil) do
|
23
23
|
err = assert_raises(RuntimeError) { make_bundle }
|
24
24
|
assert_equal 'You need to set command for minification in $JEKYLL_MINIBUNDLE_CMD_JS', err.to_s
|
25
25
|
end
|
@@ -28,7 +28,7 @@ module Jekyll::Minibundle::Test
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def make_bundle
|
31
|
-
bundle = AssetBundle.new
|
31
|
+
bundle = AssetBundle.new(:js, [site_fixture_path('_assets/scripts/dependency.js')], site_fixture_path)
|
32
32
|
bundle.make_bundle
|
33
33
|
end
|
34
34
|
end
|
@@ -8,22 +8,22 @@ module Jekyll::Minibundle::Test
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_returns_same_stamp_file_instance_for_same_destination_path
|
11
|
-
first = AssetFileRegistry.stamp_file
|
12
|
-
second = AssetFileRegistry.stamp_file
|
11
|
+
first = AssetFileRegistry.stamp_file('_assets/src1.css', 'assets/dest.css')
|
12
|
+
second = AssetFileRegistry.stamp_file('_assets/src2.css', 'assets/dest.css')
|
13
13
|
assert_same first, second
|
14
14
|
assert_equal 1, asset_file_registry_size
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_returns_same_bundle_file_instance_for_same_destination_path_and_type
|
18
|
-
first = AssetFileRegistry.bundle_file
|
19
|
-
second = AssetFileRegistry.bundle_file
|
18
|
+
first = AssetFileRegistry.bundle_file(bundle_config.merge('assets' => %w{a1 a2}))
|
19
|
+
second = AssetFileRegistry.bundle_file(bundle_config.merge('assets' => %w{b1 b2}))
|
20
20
|
assert_same first, second
|
21
21
|
assert_equal 1, asset_file_registry_size
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_bundle_files_allow_same_path_for_different_types
|
25
|
-
AssetFileRegistry.bundle_file
|
26
|
-
AssetFileRegistry.bundle_file
|
25
|
+
AssetFileRegistry.bundle_file(bundle_config.merge('type' => :css))
|
26
|
+
AssetFileRegistry.bundle_file(bundle_config.merge('type' => :js))
|
27
27
|
assert_equal 2, asset_file_registry_size
|
28
28
|
end
|
29
29
|
|
@@ -41,7 +41,7 @@ module Jekyll::Minibundle::Test
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def asset_file_registry_size
|
44
|
-
AssetFileRegistry.
|
44
|
+
AssetFileRegistry.instance_variable_get(:@_instances).size
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -5,7 +5,7 @@ module Jekyll::Minibundle::Test
|
|
5
5
|
class AssetTagMarkupTest < TestCase
|
6
6
|
def test_escapes_attribute_values
|
7
7
|
attributes = { media: 'screen, projection', extra: '">attack<br' }
|
8
|
-
actual = AssetTagMarkup.make_markup
|
8
|
+
actual = AssetTagMarkup.make_markup(:css, 'http://localhost', attributes)
|
9
9
|
expected = %{<link rel="stylesheet" href="http://localhost" media="screen, projection" extra="">attack<br">}
|
10
10
|
assert_equal expected, actual
|
11
11
|
end
|
@@ -8,36 +8,33 @@ module Jekyll::Minibundle::Test
|
|
8
8
|
|
9
9
|
def test_calling_markup_determines_fingerprint_and_destination_write
|
10
10
|
with_site do
|
11
|
-
with_env
|
12
|
-
bundle_file = BundleFile.new
|
13
|
-
source = source_path
|
14
|
-
old_destination = destination_path
|
11
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count) do
|
12
|
+
bundle_file = BundleFile.new(bundle_config)
|
13
|
+
source = source_path(JS_BUNDLE_SOURCE_DIR, 'app.js')
|
14
|
+
old_destination = destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH)
|
15
15
|
org_markup, last_markup = nil
|
16
|
+
capture_io { org_markup = bundle_file.markup }
|
16
17
|
|
17
|
-
|
18
|
-
org_markup = bundle_file.markup
|
19
|
-
bundle_file.write '_site'
|
20
|
-
end
|
18
|
+
assert bundle_file.write('_site')
|
21
19
|
|
22
|
-
org_mtime = mtime_of
|
20
|
+
org_mtime = mtime_of(old_destination)
|
23
21
|
|
24
22
|
assert_equal 1, get_cmd_count
|
25
23
|
|
26
24
|
last_markup = bundle_file.markup
|
27
|
-
ensure_file_mtime_changes { File.write
|
28
|
-
bundle_file.write '_site'
|
25
|
+
ensure_file_mtime_changes { File.write(source, '(function() {})()') }
|
29
26
|
|
30
27
|
# preserve fingerprint and content seen in last markup phase
|
28
|
+
refute bundle_file.write('_site')
|
31
29
|
assert_equal org_markup, last_markup
|
32
30
|
assert_equal org_mtime, mtime_of(old_destination)
|
33
31
|
assert_equal 1, get_cmd_count
|
34
32
|
|
35
|
-
capture_io
|
36
|
-
last_markup = bundle_file.markup
|
37
|
-
bundle_file.write '_site'
|
38
|
-
end
|
33
|
+
capture_io { last_markup = bundle_file.markup }
|
39
34
|
|
40
|
-
|
35
|
+
assert bundle_file.write('_site')
|
36
|
+
|
37
|
+
new_destination = destination_path('assets/site-375a0b430b0c5555d0edd2205d26c04d.js')
|
41
38
|
|
42
39
|
# see updated fingerprint in the next round
|
43
40
|
refute_equal org_markup, last_markup
|
@@ -49,30 +46,25 @@ module Jekyll::Minibundle::Test
|
|
49
46
|
|
50
47
|
def test_many_consecutive_markup_calls_trigger_one_destination_write
|
51
48
|
with_site do
|
52
|
-
with_env
|
53
|
-
bundle_file = BundleFile.new
|
54
|
-
source = source_path
|
55
|
-
destination = destination_path
|
49
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count) do
|
50
|
+
bundle_file = BundleFile.new(bundle_config)
|
51
|
+
source = source_path(JS_BUNDLE_SOURCE_DIR, 'app.js')
|
52
|
+
destination = destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH)
|
56
53
|
org_markup, last_markup = nil
|
54
|
+
capture_io { org_markup = bundle_file.markup }
|
55
|
+
bundle_file.markup
|
57
56
|
|
58
|
-
|
59
|
-
org_markup = bundle_file.markup
|
60
|
-
bundle_file.markup
|
61
|
-
bundle_file.write '_site'
|
62
|
-
end
|
57
|
+
assert bundle_file.write('_site')
|
63
58
|
|
64
|
-
org_mtime = mtime_of
|
59
|
+
org_mtime = mtime_of(destination)
|
65
60
|
|
66
61
|
assert_equal 1, get_cmd_count
|
67
62
|
|
68
|
-
ensure_file_mtime_changes { FileUtils.touch
|
69
|
-
|
70
|
-
|
71
|
-
last_markup = bundle_file.markup
|
72
|
-
bundle_file.markup
|
73
|
-
bundle_file.write '_site'
|
74
|
-
end
|
63
|
+
ensure_file_mtime_changes { FileUtils.touch(source) }
|
64
|
+
capture_io { last_markup = bundle_file.markup }
|
65
|
+
bundle_file.markup
|
75
66
|
|
67
|
+
assert bundle_file.write('_site')
|
76
68
|
assert_equal org_markup, last_markup
|
77
69
|
assert_operator mtime_of(destination), :>, org_mtime
|
78
70
|
assert_equal 2, get_cmd_count
|
@@ -80,6 +72,24 @@ module Jekyll::Minibundle::Test
|
|
80
72
|
end
|
81
73
|
end
|
82
74
|
|
75
|
+
def test_calling_write_before_markup_has_no_effect
|
76
|
+
with_site do
|
77
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count) do
|
78
|
+
bundle_file = BundleFile.new(bundle_config)
|
79
|
+
|
80
|
+
refute bundle_file.write('_site')
|
81
|
+
assert_empty Dir[destination_path('assets/*.js')]
|
82
|
+
assert_equal 0, get_cmd_count
|
83
|
+
|
84
|
+
capture_io { bundle_file.markup }
|
85
|
+
|
86
|
+
assert bundle_file.write('_site')
|
87
|
+
assert File.exists?(destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
88
|
+
assert_equal 1, get_cmd_count
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
83
93
|
private
|
84
94
|
|
85
95
|
def bundle_config
|