开发者

How to delete everything in side of /public/assets

In a rake task, how can I delete everything inside of the /public/assets folder?

For deployment, we jammit the assets and the md5 has them, I would like a way to delete everything in assets before running jammit and the md5.

Any suggestions?

In the current rake task we h开发者_StackOverflow中文版ave:

def get_file_paths
  Rake::FileList.new(
    './public/assets/*',
    './public/assets/**/*',
    './public/images/*',
    './public/images/**/*',
    './public/misc/*',
    './public/misc/**/*',
  )
end

def package_path
  file = open(config_file_path) {|f| YAML.load(f) }
  dir  = "public/" + (file["package_path"] || "assets")
end

Thanks for the help.


Clearly any solution you get here can be potentially very dangerous to execute or automate, so proceed with caution and thorough testing.

`rm #{RAILS_ROOT}/public/images/*`

You may also need to use sudo or certain flags depending on your needs.

*Edit: To describe what is happening here: Using the backticks allows you to execute shell commands. You are executing the rm command and then defining the absolute path to your images folder. You can modify the path or command as you see fit. Also, keep in mind this means you can affect other parts of the filesystem unrelated to your project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜