Skip to content
Permalink
Browse files

fix(test): fix non dev test builds, ensure the server stops and the b…

…uild completes
  • Loading branch information
jyounce committed May 27, 2016
1 parent a450808 commit 9f8059dfb23a500cbf9b11391f1b21762dcb7062
@@ -20,6 +20,7 @@ module.exports = (config, options) ->
file =
appServer: 'routes.js' # app server dist entry file
rbServer: # rb server dist
info: 'server-info.json'
start: 'start-server.js'
stop: 'stop-server.js'

@@ -160,6 +161,7 @@ module.exports = (config, options) ->
config.dist.rb.server.scripts.stopFile = file.rbServer.stop

_path = config.dist.rb.server.scripts.path
config.dist.rb.server.scripts.info = path.join _path, file.rbServer.info
config.dist.rb.server.scripts.start = path.join _path, file.rbServer.start
config.dist.rb.server.scripts.stop = path.join _path, file.rbServer.stop

@@ -6,8 +6,8 @@ msg = null

try
process.kill info.pid
msg = "Server stopped on port #{info.port}"
msg = "Server Stopped on Port #{info.port}"
catch e
msg = "Failed to stop the server. #{e.message}"
msg = "Failed to Stop the Server: #{e.message}"

console.log msg
@@ -2,17 +2,36 @@ module.exports = (config) ->
q = require 'q'
path = require 'path'
promiseHelp = require "#{config.req.helpers}/promise"
stopServerFile = config.dist.rb.server.scripts.stop
serverInfoFile = config.dist.rb.server.scripts.info

# helpers
# =======
stopServer = ->
serverInfo = require serverInfoFile
new Promise (resolve, reject) ->
process.on 'SIGINT', ->
process.exit 0

try
process.kill serverInfo.pid, 'SIGINT'
msg = "Server Stopped on Port #{serverInfo.port}"
console.log msg.yellow
catch e
msg = "Failed to Stop the Server: #{e.message}"
console.log msg.error
process.exit 1

resolve msg

# API
# ===
api =
runTask: ->
return promiseHelp.get() unless config.build.server
return promiseHelp.get() if config.exclude.default.server.files
defer = q.defer()
stopServer = require stopServerFile
defer.resolve()
defer = q.defer()
stopServer().then ->
defer.resolve()
defer.promise

# return

0 comments on commit 9f8059d

Please sign in to comment.
You can’t perform that action at this time.