mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:09:18 +08:00
DEV: Cleanup old theme-transpiler js files in development
This commit is contained in:
parent
8b61aafe74
commit
4715ef2bb9
|
@ -80,7 +80,28 @@ class DiscourseJsProcessor
|
|||
@mutex
|
||||
end
|
||||
|
||||
def self.prune_old_transpilers!
|
||||
return if Rails.env.production?
|
||||
|
||||
# in development/test, we have one-file-per-process, named by PID
|
||||
# Clean up the oldest ones to stop the tmp directory from growing indefinitely
|
||||
Dir["tmp/theme-transpiler/*.js"]
|
||||
.sort_by do |f|
|
||||
File.mtime(f)
|
||||
rescue Errno::ENOENT
|
||||
0 # Deleted by another process
|
||||
end
|
||||
.reverse
|
||||
.drop(50)
|
||||
.each do |f|
|
||||
File.delete(f)
|
||||
rescue Errno::ENOENT
|
||||
# Deleted by another process
|
||||
end
|
||||
end
|
||||
|
||||
def self.build_theme_transpiler
|
||||
prune_old_transpilers!
|
||||
Discourse::Utils.execute_command(
|
||||
"node",
|
||||
"app/assets/javascripts/theme-transpiler/build.js",
|
||||
|
|
Loading…
Reference in New Issue
Block a user