Skip to content
Browse files

Added option to generate an IISNode compatible site from the node scr…

…ipt. Also works on AppHarbor.
  • Loading branch information...
1 parent a4e9a61 commit d1e0c3c08b524ea0b39ed9ccd0561b7d074da49a @csainty csainty committed Feb 17, 2012
Showing with 36 additions and 4 deletions.
  1. +36 −4 node/metro.js
View
40 node/metro.js
@@ -15,17 +15,19 @@ var version = '0.0.1';
var usage = ''
+ '\n'
- + ' Usage: node metro [options|path]\n'
+ + ' Usage: node metro [options] [path]\n'
+ '\n'
+ ' Options:\n'
+ + ' -i, --iis iisnode compatibility\n'
+ ' -v, --version output framework version\n'
+ ' -h, --help output help information\n'
;
// Parse arguments
var args = process.argv.slice(2)
- , path = '.';
+ , path = '.'
+ , forIis = false;
while (args.length) {
var arg = args.shift();
@@ -38,6 +40,10 @@ while (args.length) {
case '--version':
abort(version);
break;
+ case '-i':
+ case '--iis':
+ forIis= true;
+ break;
default:
path = arg;
}
@@ -81,7 +87,7 @@ var jadeLayout = [
, ' body { width: 800px; margin: 0 auto; }'
, ' script(type=\'text/javascript\', src=\'http://code.jquery.com/jquery-1.5.1.min.js\')'
, ' script(type=\'text/javascript\', src=\'/js/jquery.metro.js\')'
- , ' body!= body'
+ , ' body.whitebg.blue!= body'
].join(eol);
/**
@@ -168,11 +174,34 @@ var app = [
, ''
, 'app.get(\'/\', routes.index);'
, ''
- , 'app.listen(3000);'
+ , 'app.listen(' + (forIis ? 'process.env.PORT' : '3000') + ');'
, 'console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);'
, ''
].join(eol);
+// IISNode web.config
+if (forIis) {
+ var webConfig = [
+ ''
+ , '<configuration>'
+ , ' <system.webServer>'
+ , ' <handlers>'
+ , ' <add name="iisnode" path="app.js" verb="*" modules="iisnode" />'
+ , ' </handlers>'
+ , ' <iisnode loggingEnabled="false" />'
+ , ' <rewrite>'
+ , ' <rules>'
+ , ' <rule name="myapp">'
+ , ' <match url="/*" />'
+ , ' <action type="Rewrite" url="app.js" />'
+ , ' </rule>'
+ , ' </rules>'
+ , ' </rewrite>'
+ , ' </system.webServer>'
+ , '</configuration>'
+ ].join(eol);
+}
+
// Generate application
(function createApplication(path) {
@@ -240,6 +269,9 @@ function createApplicationAt(path) {
write(path + '/package.json', json);
write(path + '/app.js', app);
+ if (forIis) {
+ write(path + '/web.config', webConfig);
+ }
});
}

0 comments on commit d1e0c3c

Please sign in to comment.
Something went wrong with that request. Please try again.