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

Allow downloading versions from a Node.js mirror #32

Closed
haishanh opened this issue Feb 13, 2019 · 7 comments
Closed

Allow downloading versions from a Node.js mirror #32

haishanh opened this issue Feb 13, 2019 · 7 comments

Comments

@haishanh
Copy link

haishanh commented Feb 13, 2019

This is a feature request.

When I already have ~/.fnm/downloads/v11.9.0.tar.xz exists on disk, if I run fnm install 11.9.0, I would like fnm to try to unarchive it first and starting to download the fresh package only if unarchive exits with none zero status.

I use Taobao's node dist mirror. It's faster than Nodejs's 1st party one since I'm in China.(Taobao is a Alibaba company)

As a example:

# I use this url
https://npm.taobao.org/dist/v11.9.0/node-v11.9.0-darwin-x64.tar.xz
# instead of
https://nodejs.org/dist/v11.9.0/node-v11.9.0-darwin-x64.tar.xz
@Schniz
Copy link
Owner

Schniz commented Feb 13, 2019

Interesting: there's already #27, but that's not what you're talking about.
Looking for an existing archive feels like treating the symptom and not the actual problem we have:
I guess we can also support npm.taobao.org, only by changing the hard-coded https://nodejs.org to an environment variable.

Do you think it is a better fix for the problem? 😄

eval `fnm env --node-dist-url="https://npm.taobao.org/dist"`
# then everything as expected
fnm install v11.9.0

@haishanh
Copy link
Author

haishanh commented Feb 13, 2019

Yes! that would be better. 😀

I use tj/n before trying out fnm. You can almost do the same thing with n, see https://github.com/tj/n/blob/master/bin/n#L32

@Schniz
Copy link
Owner

Schniz commented Feb 13, 2019

Amazing. Can you please edit the title of this issue then? Something like "Allow downloading versions from a Node.js mirror" 😄

@haishanh haishanh changed the title Skip download node archive if it's already exists on disk Allow downloading versions from a Node.js mirror Feb 13, 2019
@haishanh
Copy link
Author

Done. Thanks :)

@haishanh
Copy link
Author

Also, to keep it simple I don't think it's worth it to implement a new option (here --node-dist-url) for fnm env command. Reading an env var with a default value directly inside fnm is enough IMHO.

@Schniz
Copy link
Owner

Schniz commented Feb 13, 2019

I generally agree about this, but I somehow liked the idea of making environment variables an internal implementation (since we already have a call that generates environment variables). It feels like a typed interface 😜

That being said, it can always be set manually (right after/before the fnm env), but co-locating it with the fnm env command makes it clear what is it for (and how to get information about it, using --help 😄)

@haishanh
Copy link
Author

Yeah, that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants