diff --git a/.gitignore b/.gitignore index 602c5da..7f12a4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules tmp npm-debug.log +.vscode \ No newline at end of file diff --git a/lib-src/cfenv.coffee b/lib-src/cfenv.coffee index 0252bd5..5aca35a 100644 --- a/lib-src/cfenv.coffee +++ b/lib-src/cfenv.coffee @@ -174,7 +174,10 @@ getPort = (appEnv) -> unless portString? return 3000 unless appEnv.name? - portString = "#{ports.getPort appEnv.name}" + try + portString = "#{ports.getPort appEnv.name}" + catch e + portString = '3000' port = parseInt portString, 10 throwError "invalid PORT value: /#{portString}/" if isNaN port diff --git a/lib/cfenv.js b/lib/cfenv.js index 6b7fcfb..3aa2785 100644 --- a/lib/cfenv.js +++ b/lib/cfenv.js @@ -215,13 +215,18 @@ }; getPort = function(appEnv) { - var port, portString, ref; + var e, port, portString, ref; portString = process.env.PORT || process.env.CF_INSTANCE_PORT || process.env.VCAP_APP_PORT || (appEnv != null ? (ref = appEnv.app) != null ? ref.port : void 0 : void 0); if (portString == null) { if (appEnv.name == null) { return 3000; } - portString = "" + (ports.getPort(appEnv.name)); + try { + portString = "" + (ports.getPort(appEnv.name)); + } catch (error) { + e = error; + portString = '3000'; + } } port = parseInt(portString, 10); if (isNaN(port)) {