sindresorhus / gulp-rev

Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
MIT License
1.54k stars 218 forks source link

Line order on rev-manifest #112

Closed gothy closed 9 years ago

gothy commented 9 years ago

Hi

I'm trying to make this merging this work the way I expect and failing in this. Each time I'm running gulp-rev on unchanged repo, I can see changes in rev-manifest.json output. Everything is fine except the line order in output. So merging is OK, tail revisions are fine, but I get a diff in git each time. I know it's not very nice to have build/dist sitting in the repo, but this is a requirement for now. Is there any way to force the output be exactly the same when running with merge: true?

Thanks!

bobthecow commented 9 years ago

Your best bet would be to pipe the manifest through something to sort it alphabetically by keys before writing it to disk. Otherwise, the merge will just move whatever's new to the bottom.

sindresorhus commented 9 years ago

I guess we could sort the keys when merging. Don't see any downside doing that. npm does so to with package.json dependencies.

bobthecow commented 9 years ago

Yeah, I don't have a strong preference one way or the other. Sorting the keys seems like a sane default?

bobthecow commented 9 years ago

If we're going to sort on merge, we should sort 'em even if we don't merge, since directory order is nondeterministic.

sindresorhus commented 9 years ago

Yes, let's go with that.

gothy commented 9 years ago

Wow... that was fast :) Can I hope to see an update soon on npm? :) Thanks a lot!

JonWallsten commented 8 years ago

I'm here because sorting the keys ruins it for me! Is it possible to use this as an option instead?

I need the files in the original order because all vendor files needs to be in the beginning.

timcosta commented 8 years ago

Given that it's a hash map and there is no additional complexity accessing keys farther down the list, why do vendor files need to be at the top?

Either way, this isn't something we are likely to support. I recommend writing a custom parser using fs and JSON.parse to achieve what you are looking for.