From 44f733f59fc4aae650605228ff66cc9313683c42 Mon Sep 17 00:00:00 2001 From: Jonathan Sheely Date: Wed, 29 Apr 2015 16:37:26 -0400 Subject: [PATCH] Support iisnode using named pipes as PORT value Port can't be number checked to support iisnode. Using a parseInt() or number isNumber function won't work if we want to support iisnode which uses named pipes for ports (ex. \\.\pipe\mypipe) --- lib/executor.js | 4 +++- test/executor.test.js | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/executor.js b/lib/executor.js index 5198d7f..84c0605 100644 --- a/lib/executor.js +++ b/lib/executor.js @@ -115,7 +115,9 @@ function setPort(app, instructions) { process.env.npm_package_config_port, app.get('port'), 3000 - ], isFinite); + ], function(p) { + return p != null; + }); if (port !== undefined) { var portType = typeof port; diff --git a/test/executor.test.js b/test/executor.test.js index 997c253..30da00d 100644 --- a/test/executor.test.js +++ b/test/executor.test.js @@ -417,10 +417,11 @@ describe('executor', function() { assert.equal(app.get('port'), 3000); }); - it('should ignore non-numeric port values in ENV', function() { - process.env.PORT = '123invalid'; + it('should respect named pipes port values in ENV', function() { + var NAMED_PORT = '\\.\\pipe\\test'; + process.env.PORT = NAMED_PORT; boot.execute(app, someInstructions({ config: { port: 3000 } })); - assert.equal(app.get('port'), 3000); + assert.equal(app.get('port'), NAMED_PORT); }); });