-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support .slugignore
#9
Comments
Also, should remember to update the README to reflect this (removing the TODO) |
https://github.com/denormal/go-gitignore < this should be useful |
alternatively: https://github.com/sabhiram/go-gitignore i've tried both out, but they both seem to be missing some edge cases from some rough testing 😞 Not sure if I want to implement my own Heroku doesn't support the |
This might be useful though as a guide? |
Closes: #9 Adds support for `.slugignore` files. `prepare` will now only copy files which do not match any entry in the `.slugignore` file for a given `source-dir`. The logic is intended to follow logic similar to [this](https://github.com/heroku/slug-compiler/blob/68b63a30907f171e60f8398463d6bbd13b4ed178/lib/slug_compiler.rb#L131-L152): ```ruby lines = File.read(slugignore_path).split total = lines.inject(0) do |total, line| line = (line.split(/#/).first || "").strip if line.empty? total else globs = if line =~ /\// [File.join(build_dir, line)] else # 1.8.7 and 1.9.2 handle expanding ** differently, # where in 1.9.2 ** doesn't match the empty case. So # try empty ** explicitly ["", "**"].map { |g| File.join(build_dir, g, line) } end to_delete = Dir[*globs].uniq.map { |p| File.expand_path(p) } to_delete = to_delete.select { |p| p.match(/^#{build_dir}/) } to_delete.each { |p| FileUtils.rm_rf(p) } total + to_delete.size end end ``` Which as far as I can tell has not changes since Heroku closed-source their compiler, which can be verified by extracting the builder source from Heroku via a custom buildpack.
.slugignore
files can be used to nuke a bunch of files/folders from the final slug, making it smaller.See: https://devcenter.heroku.com/articles/slug-compiler#ignoring-files-with-slugignore
Should be feasible by using the
Skip
options in https://pkg.go.dev/github.com/otiai10/copy#OptionsThe text was updated successfully, but these errors were encountered: