Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move start-lineman into a grunt task #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/plugins/spec-browser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = (lineman) ->
browser:
root: "spec-browser"
helpers: [
"#{__dirname}/../../helpers/start-lineman.coffee"
"#{__dirname}/../../helpers/browser.coffee"
"<%= files.spec.browser.root %>/helpers/**/*.{js,coffee}"
]
Expand Down
22 changes: 0 additions & 22 deletions helpers/start-lineman.coffee

This file was deleted.

36 changes: 36 additions & 0 deletions tasks/start-lineman.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
http = require 'http'

module.exports = (grunt) ->

grunt.registerTask 'startLineman', 'starts an instance of lineman if one is not running', ->

process.env.WEB_PORT = port = process.env.WEB_PORT || 8001
process.env.LINEMAN_ENV = "test"

done = @async()
http.get("http://localhost:#{port}", (res) ->
console.log 'A server appears to already be running on port #{port}.'
done()
).on 'error', (err) ->

global.currentLineman = lineman = grunt.util.spawn
cmd: "lineman"
args: ["run"]
opts:
detached: true

lineman.stdout.on "data", (data) ->
if ~data.toString().indexOf("Waiting...")
console.log("Started a Lineman server on port #{port}.")
done()

process.on 'exit', ->
# Quit browser
global.browser?.quit()

# If we started a lineman process, kill it and
# any child node processes
console.log 'Shutting down lineman'
lineman.kill()
require('child_process').exec('pkill node', ->)