Skip to content
This repository
Browse code

[checks] check if server.js even exists before trying to run it

  • Loading branch information...
commit 74ac13d9054a84fc0b2b5ee1ef47611b3fb3be24 1 parent 40eca1d
Edward Hotchkiss authored March 26, 2012
14  lib/node-angular/server.js
@@ -5,10 +5,20 @@
5 5
  * @param {Number} port Port to run Express/Node on
6 6
  */
7 7
 
  8
+var path = require('path')
  9
+  , utils = require('./utils');
  10
+
8 11
 var server = module.exports = function(args) {
9 12
   var port = (args.length > 0) ? args[0] : 9000;
10  
-  var serverFile = require(process.cwd() + '/server.js');
11  
-  serverFile.listen(port);
  13
+  var server = process.cwd() + '/server.js'
  14
+  path.exists(server, function(exists) {
  15
+    if (exists) {
  16
+      var serverFile = require(server);
  17
+      serverFile.listen(port);
  18
+    } else {
  19
+      utils.log('warn', 'No server.js file found!');
  20
+    };
  21
+  });
12 22
 };
13 23
 
14 24
 /* EOF */
11  lib/node-angular/utils.js
@@ -61,11 +61,18 @@ var log = utils.log = function(type, message) {
61 61
     case 'create':
62 62
       console.log('create'.green + ' ' + message);
63 63
       break;
  64
+    case 'patch':
  65
+      console.log('patch'.magenta + ' ' + message);
  66
+      break;
  67
+    case 'warn':
  68
+      console.log('warn'.yellow.inverse + ' ' + message);
  69
+      break;
  70
+    case 'error':
  71
+      console.log('create'.red.inverse + ' ' + message);
  72
+      break;
64 73
     default:
65 74
       break;
66 75
   };
67 76
 };
68 77
 
69  
-/*
70  
-
71 78
 /* EOF */

0 notes on commit 74ac13d

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