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

Add mutator method for basePath #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/portfinder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,13 @@ export function getPorts(count: number, options: PortFinderOptions, callback: (e
* Responds a promise of an unbound port on the current machine.
*/
export function getPortPromise(options?: PortFinderOptions): Promise<number>;

/**
* Default path to begin any socket search from.
*/
export let basePath: string;

/**
* Set the base path to begin any socket search from.
*/
export function setBasePath(path: string): void;
7 changes: 7 additions & 0 deletions lib/portfinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ exports.setHighestPort = function (port) {
exports.basePath = '/tmp/portfinder'

//
// ### function setBasePath (path)
// #### @path {String} The new base path
//
exports.setBasePath = function (path) {
exports.basePath = path;
}

// ### function getPort (options, callback)
// #### @options {Object} Settings to use when finding the necessary port
// #### @callback {function} Continuation to respond to when complete.
Expand Down