Skip to content
This repository was archived by the owner on Jun 10, 2018. It is now read-only.

Commit d52c9df

Browse files
committed
Ensure dirname of manifest filename is always created
1 parent 54c9f50 commit d52c9df

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/sprockets/manifest.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ def find_asset(logical_path)
222222

223223
# Persist manfiest back to FS
224224
def save
225-
::FileUtils.mkdir_p dir
226-
File.open(path, 'w') do |f|
225+
::FileUtils.mkdir_p File.dirname(filename)
226+
File.open(filename, 'w') do |f|
227227
f.write json_encode(@data)
228228
end
229229
end

test/test_manifest.rb

+15
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ def teardown
102102
assert_equal digest_path, data['assets']['application.js']
103103
end
104104

105+
test "compile to directory and seperate location" do
106+
root = File.join(Dir::tmpdir, 'public')
107+
dir = File.join(root, 'assets')
108+
path = File.join(root, 'manifests', 'manifest-123.json')
109+
110+
system "rm -rf #{root}"
111+
assert !File.exist?(root)
112+
113+
manifest = Sprockets::Manifest.new(@env, dir, path)
114+
115+
manifest.compile('application.js')
116+
assert File.directory?(manifest.directory)
117+
assert File.file?(manifest.filename)
118+
end
119+
105120
test "compile asset with absolute path" do
106121
digest_path = @env['application.js'].digest_path
107122

0 commit comments

Comments
 (0)