Skip to content
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

Should use the most recent file when multiple sprockets manifest files are found #1023

Closed
ynonp opened this issue Jan 28, 2018 · 9 comments
Closed

Comments

@ynonp
Copy link

ynonp commented Jan 28, 2018

A specific setup I had combining ReactOnRails with capistrano-rails had temporarily put multiple sprockets manifest files in public/assets when assets:precompile task was called.

This failed in file lib/react_on_rails/assets_precompile.rb line 75:

manifest_path = manifest_glob.first

A better approach would be to take the most recent one with:

manifest_path = manifest_glob.sort_by { |name| File.mtime(name) }.last

(Or raise an exception explaining the problem when multiple sprockets manifest files are found)

@justin808
Copy link
Member

@ynonp should we have a PR for this?

@robwise, @samnang any opinion?

@robwise
Copy link
Contributor

robwise commented Feb 6, 2018

I can't really remember the details of why we use a glob instead of an exact file path in the first place, like what is the use case for having manifest files with varying names?

@ynonp
Copy link
Author

ynonp commented Feb 6, 2018

I think part of the name of the manifest file is a hash code, and it's hard to know that hash. Anyways it's just one line, the code I wrote above works and takes the most recent manifest file, which is always a better guess than the first in the glob list

@ynonp
Copy link
Author

ynonp commented Feb 6, 2018

I could make it a PR if you prefer. Just let me know

@justin808
Copy link
Member

@ynonp Yes, please make a PR and make sure some test fails without and the same test passes with your change. And add an entry to the CHANGELOG.md.

@justin808
Copy link
Member

@ynonp Any word on making a PR?

@justin808
Copy link
Member

@samnang, @mapreal19 agree this seems to make sense?

manifest_path = manifest_glob.sort_by { |name| File.mtime(name) }.last

@mapreal19
Copy link
Member

@justin808 yeah, we should just extract the method for hinting the intent by @ynonp. Something like take_most_recent_manifest_path

justin808 added a commit that referenced this issue Apr 21, 2018
When creating symlinks, use the most recent manifest found.

See #1023
justin808 added a commit that referenced this issue Apr 21, 2018
When creating symlinks, use the most recent manifest found.

See #1023
@justin808
Copy link
Member

Fixed in #1064

justin808 added a commit that referenced this issue Apr 21, 2018
When creating symlinks, use the most recent manifest found.

See #1023
justin808 added a commit that referenced this issue Apr 22, 2018
When creating symlinks, use the most recent manifest found.

See #1023
justin808 added a commit that referenced this issue Apr 22, 2018
When creating symlinks, use the most recent manifest found.

See #1023
superdev9082 added a commit to superdev9082/react_on_rails that referenced this issue Feb 16, 2023
When creating symlinks, use the most recent manifest found.

See shakacode/react_on_rails#1023
Web-Go-To added a commit to Web-Go-To/react-with-rails that referenced this issue Mar 19, 2023
When creating symlinks, use the most recent manifest found.

See shakacode/react_on_rails#1023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants