http-party / node-portfinder

A simple tool to find an open port or domain socket on the current machine
https://github.com/http-party/node-portfinder
Other
882 stars 95 forks source link

Add mutator methods to allow ports ranges to be set with module-style imports #115

Closed inlined closed 2 years ago

inlined commented 3 years ago

Ran into a compiler error when using portfinder in TypeScript. Module exports are considered immutable in typescript, so the following code won't compile:

import * as portfinder from "portfinder";

portfinder.basePort = 3000;

Instead, a new accessor method allows us to say portfinder.setBasePort(3000);

inlined commented 3 years ago

Ping?

eriktrom commented 3 years ago

yep sorry for the delay

so unfortunately this lib has to work with node going back as far as v0.10.x - as enterprise code bases, believe it or not, sometimes never upgrade node itself, and this lib is used by more packages than one would at first imagine.

thanks though for being awesome and contributing. despite having to close this, i highly respect those who contribute to open source and I wish I could merge this for that sake alone but unfortunately i can't, there should be a contribution attempt chart b/c i think its such an important part of today's economy and society but until then, thanks will have to do :)

cheers

inlined commented 3 years ago

I'm confused. Why does offering a mutator method affect the version of node that can be used? The opposite is true; without this change portfinder won't be able to be used in a modern codebase but with this change it can be used in old or new codebases.

eriktrom commented 2 years ago

@inlined - I will revisit this per @MasterOdin's remarks on the issue I left, the same day I made my comment above your's. (Almost 1 year ago to the date)

Re-opening.

eriktrom commented 2 years ago

I'm confused. Why does offering a mutator method affect the version of node that can be used? The opposite is true; without this change portfinder won't be able to be used in a modern codebase but with this change it can be used in old or new codebases.

Correct.

PS - Sorry I haven't been around for the last 12 months. Knowing that was going to be the case, I left an issue at https://github.com/http-party/node-portfinder/issues/122 - which until 4 days ago was mostly crickets. I have returned and will address the outstanding PR's and issues.

Thanks for your patience.