narirou / gulp-develop-server

Development assistant for node.js server by gulp
MIT License
70 stars 11 forks source link

Run coffee #17

Open pronebird opened 9 years ago

pronebird commented 9 years ago

Hi,

I have a bootstrap coffee script that I run with gulp-develop-server:

#!/usr/bin/env coffee

app = require '../src/app'
http = require 'http'

port = process.env.PORT or '3000'
app.set 'port', port

server = http.createServer app
server.listen port

I have tried to pass my script with path option to gulp-develop-server but it would run my script with node instead. Then I looked at the source code and figured that there is an execPath parameter which seem to do the trick.

gulp.task 'server:start', ->
  server.listen
    path: ''
    execPath: 'bin/www'
    env: require './config.json'
  return

gulp.task 'server:restart', ->
  server.restart()
  return

My question is, is it normal that I pass an empty path and provide custom execPath for my coffee script?

pronebird commented 9 years ago

The fun part that empty path crashes server on restart. As a workaround I pass the same configuration for both execPath and path. It does not look right to me, but it works.

gulp.task 'server:start', ->
  server.listen
    path: 'bin/www'
    execPath: 'bin/www'
    env: require './config.json'
  return