twolfson / grunt-curl

Download files from the internet via grunt.
The Unlicense
73 stars 28 forks source link

Can we use dynamic paths? #42

Closed uglyeoin closed 5 years ago

uglyeoin commented 5 years ago

Can we use dynamic paths?

I have a file but the version number is appended to each file name. So:

file-1.2.3.zip

Can we achieve this with this repository?

twolfson commented 5 years ago

Can you elaborate more? Is this the URL that has a dynamic path? The filepath where it should be saved to that's dynamic?

uglyeoin commented 5 years ago

The URL I am getting it from is e.g. www.blah.com/downloads/file-version-1.2.3.zip

If you see my dilemma is that the URL will keep changing unless we can use wildcards or something.

twolfson commented 5 years ago

Is there a way to know the URL ahead of time without viewing the listing page?

uglyeoin commented 5 years ago

I think the most ideal scenario is some logic like:

if file-version-1.2.3.zip = 404 then try version-1.2.4.zip

I guess at some point I need a timeout to try

1.3.0

I can only tell you the URL is incremented, I can't really tell you when

twolfson commented 5 years ago

This is not possible to do with this library. It's built for known URLs. We might have been able to get away with a synchronous HTTP request at load time but multiple guesses seems excessive

This issue seems even too complex for grunt in general unless you define a custom plugin. In that scenario, you're prob better off writing a generic function/script to do all this logic for you -- maybe add a grunt wrapper for it if you need to use it via a grunt task

uglyeoin commented 5 years ago

Cool, thanks for responding. Still looks like a great plugin.