Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (argv.useLocalIp) { options.useLocalIp = true; }
// Kind of weird, but ensures prior behavior isn't broken in cases
// that wouldn't throw errors. E.g. both argv.port and options.port
// were specified, but since argv.port is 8080, options.port will be
// tried first instead.
options.port = argv.port === DEFAULT_PORT ? defaultTo(options.port, argv.port) : defaultTo(argv.port, options.port);
if (options.port != null) {
startDevServer(webpackOptions, options);
return;
}
portfinder.basePort = DEFAULT_PORT;
portfinder.getPort((err, port) => {
if (err) throw err;
options.port = port;
startDevServer(webpackOptions, options);
});
}
if (options.open && !options.openPage) {
options.openPage = '';
}
if (!options.host) {
options.host = 'localhost';
}
if (options.port) {
startDevServer(finalConfig, options);
return;
}
portfinder.basePort = DEFAULT_PORT;
portfinder.getPort((err, port) => {
if (err) throw err;
options.port = port;
startDevServer(finalConfig, options);
});
function colorInfo(useColor, msg) {
if (useColor) {
// Make text blue and bold, so it *pops*
return `\u001b[1m\u001b[34m${msg}\u001b[39m\u001b[22m`;
}
return msg;
}
function colorError(useColor, msg) {
if (useColor) {
// Make text red and bold, so it *pops*
export function launchServer(
dataPath: string,
contextPath: string = __dirname
) {
portfinder.getPort((err: Error, port: number) => {
if (err != null) {
console.log(err);
process.exit(1);
}
const app = express();
app.use(express.static(path.join(contextPath, VIZ_PATH)));
console.log(path.join(contextPath, VIZ_PATH));
app.listen(port, "0.0.0.0", () => {
console.log(`Server running on port ${port}`);
console.log(`Press Control+C to Quit`);
opn(`http://localhost:${port}/?file=${dataPath}`);
});
});
}
function edit(done) {
portfinder.getPort({port: 5000}, function (err, port) {
var app = connect();
app.use(swaggerRepo.swaggerEditorMiddleware());
app.listen(port);
log(colors.green('swagger-editor started http://localhost:' + port));
});
done();
}
return new Promise((resolve, reject) => {
require("portfinder").getPort({ port: STARTING_PORT }, function(err, port) {
if (err) {
reject(err);
} else {
resolve(port);
}
});
});
}
this.sock = new axon.types[this.type]();
this.sock.sock.on('bind', () => this.startDiscovery());
const onPort = (err, port) => {
this.advertisement.port = +port;
this.sock.bind(port);
this.sock.sock.server.on('error', err => {
if (err.code != 'EADDRINUSE') throw err;
portfinder.getPort({
host: this.discoveryOptions.address,
port: this.advertisement.port
}, onPort);
});
};
portfinder.getPort({
host: this.discoveryOptions.address,
port: advertisement.port
}, onPort);
}
const onPort = (err, port) => {
advertisement.port = +port;
this.sock.bind(port);
this.sock.sock.server.on('error', (err) => {
if (err.code != 'EADDRINUSE') throw err;
portfinder.getPort({
host: this.discoveryOptions.address,
port: this.advertisement.port,
}, onPort);
});
};
portfinder.getPort({
host: this.discoveryOptions.address,
port: this.advertisement.port,
}, onPort);
}
this.sock.sock.server.on('error', err => {
if (err.code != 'EADDRINUSE') throw err;
portfinder.getPort({
host: this.discoveryOptions.address,
port: this.advertisement.port
}, onPort);
});
};
});
return;
}
const options = createConfig(config, argv, { port: DEFAULT_PORT });
portfinder.basePort = DEFAULT_PORT;
if (options.port != null) {
startDevServer(config, options);
return;
}
portfinder.getPort((err, port) => {
if (err) {
throw err;
}
options.port = port;
startDevServer(config, options);
});
}