Skip to content

Commit

Permalink
Fix scripts on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina authored and IgorMinar committed Nov 13, 2012
1 parent 483b38e commit 34407b7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 33 deletions.
3 changes: 2 additions & 1 deletion scripts/e2e-test.bat
@@ -1,7 +1,8 @@
@echo off

REM Windows script for running e2e tests
REM You have to run server and capture some browser first
REM Make sure you run web server first by
REM ./scripts/web-server.bat
REM
REM Requirements:
REM - NodeJS (http://nodejs.org/)
Expand Down
1 change: 0 additions & 1 deletion scripts/test.bat
@@ -1,7 +1,6 @@
@echo off

REM Windows script for running unit tests
REM You have to run server and capture some browser first
REM
REM Requirements:
REM - NodeJS (http://nodejs.org/)
Expand Down
19 changes: 0 additions & 19 deletions scripts/watchr.rb

This file was deleted.

1 change: 1 addition & 0 deletions scripts/web-server.bat
@@ -0,0 +1 @@
node "%~dp0\..\server\start.js" %*
7 changes: 0 additions & 7 deletions scripts/web-server.js

This file was deleted.

5 changes: 5 additions & 0 deletions scripts/web-server.sh
@@ -0,0 +1,5 @@
#!/bin/bash

BASE_DIR=`dirname $0`

node $BASE_DIR/../server/start.js $*
15 changes: 10 additions & 5 deletions server/index.js
Expand Up @@ -113,10 +113,15 @@ exports.start = function(PORT, STATIC_DIR, DATA_FILE) {
});


process.on('SIGINT', function() {
// save the storage back to the json file
fs.writeFile(DATA_FILE, JSON.stringify(storage.getAll()), function() {
process.exit(0);
// Windows and Node.js before 0.8.9 would crash
// https://github.com/joyent/node/issues/1553
try {
process.on('SIGINT', function() {
// save the storage back to the json file
fs.writeFile(DATA_FILE, JSON.stringify(storage.getAll()), function() {
process.exit(0);
});
});
});
} catch (e) {}

};
5 changes: 5 additions & 0 deletions server/start.js
@@ -0,0 +1,5 @@
var PORT = process.argv[2] && parseInt(process.argv[2], 10) || 3000;
var STATIC_DIR = __dirname + '/../app';
var DATA_FILE = __dirname + '/data/restaurants.json';

require('./index').start(PORT, STATIC_DIR, DATA_FILE);

0 comments on commit 34407b7

Please sign in to comment.