Skip to content

Commit 01e4a82

Browse files
committed
Fall back writing prism sources to the current directory
1 parent 4e3625f commit 01e4a82

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

prism/templates/template.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,14 @@ def render(name, write_to: nil)
643643
end
644644
end
645645

646-
FileUtils.mkdir_p(File.dirname(write_to))
647-
File.write(write_to, contents)
646+
begin
647+
FileUtils.mkdir_p(File.dirname(write_to))
648+
File.write(write_to, contents)
649+
rescue SystemCallError # EACCES, EPERM, EROFS, etc.
650+
# Fall back to the current directory
651+
FileUtils.mkdir_p(File.dirname(name))
652+
File.write(name, contents)
653+
end
648654
end
649655

650656
private

0 commit comments

Comments
 (0)