Permalink
Browse files

Update plugins to reflect latest changes in start_stop

  • Loading branch information...
1 parent 63995ee commit dd83db929e76e590c60bf3edf38176719c0d0398 @wdavidw committed Dec 5, 2011
@@ -26,7 +26,6 @@ module.exports = (settings = {}) ->
args.push '-p'
args.push settings.port
"cloud9 #{args.join(' ')}"
- cloud9 = null
(req, res, next) ->
app = req.shell
# Caching
@@ -35,19 +34,22 @@ module.exports = (settings = {}) ->
# Workspace
settings.workspace ?= app.set 'workspace'
return next(new Error 'No workspace provided') unless settings.workspace
+ settings.cmd = cmd()
# Register commands
app.cmd 'cloud9 start', 'Start Cloud9', (req, res, next) ->
# Launch process
- cloud9 = start_stop.start app, settings, cmd(), (err, pid) ->
+ start_stop.start settings, (err, pid) ->
return next err if err
- return res.cyan('Cloud9 already started').ln() and res.prompt() unless pid
+ unless pid
+ res.cyan('Cloud9 already started').ln()
+ return res.prompt()
ip = settings.ip or '127.0.0.1'
port = settings.port or 3000
message = "Cloud9 started http://#{ip}:#{port}"
res.cyan( message ).ln()
res.prompt()
app.cmd 'cloud9 stop', 'Stop Cloud9', (req, res, next) ->
- start_stop.stop app, settings, cloud9 or cmd(), (err, success) ->
+ start_stop.stop settings, (err, success) ->
if success
then res.cyan('Cloud9 successfully stoped').ln()
else res.magenta('Cloud9 was not started').ln()
@@ -20,7 +20,6 @@ module.exports = (settings = {}) ->
# Default settings
settings.workspace ?= shell.set 'workspace'
throw new Error 'No workspace provided' if not settings.workspace
- coffee = null
cmd = () ->
args = []
# Before compiling, concatenate all scripts together in the
@@ -59,9 +58,10 @@ module.exports = (settings = {}) ->
args.push '-c'
args.push enrichFiles(settings.compile)
cmd = 'coffee ' + args.join(' ')
+ settings.cmd = cmd()
# Register commands
shell.cmd 'coffee start', 'Start CoffeeScript', (req, res, next) ->
- coffee = start_stop.start shell, settings, cmd(), (err, pid) ->
+ start_stop.start settings, (err, pid) ->
return next err if err
return res.cyan('Already Started').ln() unless pid
ip = settings.ip or '127.0.0.1'
@@ -70,7 +70,7 @@ module.exports = (settings = {}) ->
res.cyan( message ).ln()
res.prompt()
shell.cmd 'coffee stop', 'Stop CoffeeScript', (req, res, next) ->
- start_stop.stop shell, settings, coffee or cmd(), (err, success) ->
+ start_stop.stop settings, (err, success) ->
if success
then res.cyan('CoffeeScript successfully stoped').ln()
else res.magenta('CoffeeScript was not started').ln()
@@ -29,14 +29,15 @@ module.exports = () ->
# Messages
settings.message_start ?= 'HTTP server successfully started'
settings.message_stop ?= 'HTTP server successfully stopped'
+ settings.cmd = cmd()
app.cmd 'http start', 'Start HTTP server', (req, res, next) ->
- http = start_stop.start app, settings, cmd(), (err, pid) ->
+ http = start_stop.start settings, (err, pid) ->
return next err if err
return res.cyan('HTTP server already started').ln() and res.prompt() unless pid
res.cyan( 'HTTP server started' ).ln()
res.prompt()
app.cmd 'http stop', 'Stop HTTP server', (req, res, next) ->
- start_stop.stop app, settings, http or cmd(), (err, success) ->
+ start_stop.stop settings, (err, success) ->
if success
then res.cyan('HTTP server successfully stoped').ln()
else res.magenta('HTTP server was not started').ln()
@@ -3,8 +3,6 @@ start_stop = require '../start_stop'
module.exports = () ->
settings = {}
- cmd = () ->
- "redis-server #{settings.config}"
# Register commands
redis = null
route = (req, res, next) ->
@@ -15,15 +13,18 @@ module.exports = () ->
# Default settings
settings.workspace ?= app.set 'workspace'
settings.config ?= ''
+ settings.cmd = "redis-server #{settings.config}"
app.cmd 'redis start', 'Start Redis', (req, res, next) ->
# Launch process
- redis = start_stop.start app, settings, cmd(), (err, pid) ->
+ redis = start_stop.start settings, (err, pid) ->
return next err if err
- return res.cyan('Redis already started').ln() && res.prompt() unless pid
+ unless pid
+ res.cyan('Redis already started').ln()
+ return res.prompt()
res.cyan('Redis started').ln()
res.prompt()
app.cmd 'redis stop', 'Stop Redis', (req, res, next) ->
- start_stop.stop app, settings, redis or cmd(), (err, success) ->
+ start_stop.stop settings, (err, success) ->
if success
then res.cyan('Redis successfully stoped').ln()
else res.magenta('Redis was not started').ln()
@@ -82,6 +82,7 @@ start_stop.start = (settings, callback) ->
process.nextTick ->
# Block the command if not in shell and process is attached
#return if not shell.isShell and settings.daemon
+ settings.pid = c.pid
callback null, c.pid
start_stop.stop = (settings, callback) ->
View
@@ -21,6 +21,9 @@
"each": "latest",
"pad": "latest"
},
+ "devDependencies": {
+ "express": "latest"
+ },
"keywords": ["cli", "console", "colors", "xterm"],
"repository": {
"type": "git",
@@ -6,7 +6,7 @@ module.exports =
'Test # plugin # throw # print error': (next) ->
stdout = new shell.NullStream
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test error'
stdin: new shell.NullStream
stdout: stdout
@@ -24,7 +24,7 @@ module.exports =
next()
'Test # plugin # throw # emit error': (next) ->
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test error'
stdin: new shell.NullStream
stdout: new shell.NullStream
@@ -39,7 +39,7 @@ module.exports =
next()
'Test # no plugin # next # emit error': (next) ->
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test error'
stdin: new shell.NullStream
stdout: new shell.NullStream
@@ -6,14 +6,14 @@ http = require 'http'
module.exports =
'Http start/stop': (next) ->
app = shell
- workspace: "#{__dirname}/PluginsHtpp"
+ workspace: "#{__dirname}/PluginsHttp"
command: null
stdin: new shell.NullStream
stdout: new shell.NullStream
app.configure ->
#app.use shell.history(shell: app)
#app.use shell.completer(shell: app)
- app.use shell.http
+ app.use shell.http attach: true
app.use shell.router shell: app
#app.use shell.error shell: app
app.run 'http start'
File renamed without changes.
@@ -5,7 +5,7 @@ assert = require 'assert'
module.exports =
'Test simple': (next) ->
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test simple'
stdin: new shell.NullStream
stdout: new shell.NullStream
@@ -16,7 +16,7 @@ module.exports =
next()
'Test param # string': (next) ->
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test my_value'
stdin: new shell.NullStream
stdout: new shell.NullStream
@@ -28,7 +28,7 @@ module.exports =
next()
'Test param # special char': (next) ->
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test 12.32/abc'
stdin: new shell.NullStream
stdout: new shell.NullStream
@@ -40,7 +40,7 @@ module.exports =
next()
'Test # param with restriction # ok': (next) ->
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test 9034'
stdin: new shell.NullStream
stdout: new shell.NullStream
@@ -54,7 +54,7 @@ module.exports =
assert.ok false
'Test # param with restriction # error': (next) ->
app = shell
- workspace: "#{__dirname}/plugins_http"
+ workspace: "#{__dirname}/PluginsHttp"
command: 'test abc'
stdin: new shell.NullStream
stdout: new shell.NullStream

0 comments on commit dd83db9

Please sign in to comment.