Permalink
Browse files

Fix commandline invocation

  • Loading branch information...
marcuswestin committed Apr 30, 2012
1 parent 07eccd2 commit c3147c09ad7496e88f29e052cb61ff0fb90a6e4f
Showing with 11 additions and 5 deletions.
  1. +1 −2 bin/fun
  2. +10 −3 src/dev-server.js
View
@@ -12,8 +12,7 @@ var commandline = optimist.usage('Usage: fun [compile] path/to/app.fun [--port=8
argv = commandline.argv,
line = argv._,
compile = line[0] == 'compile',
- filenameRaw = (compile ? line[1] : line[0]),
- filename = filenameRaw && filenameRaw[0] == '/' ? filenameRaw : path.join(process.cwd(), filenameRaw)
+ filename = (compile ? line[1] : line[0])
var opts = {
'minify': argv['minify'] == 'true',
View
@@ -4,7 +4,8 @@ var socketIo = require('socket.io'),
curry = require('std/curry'),
fs = require('fs'),
path = require('path'),
- time = require('std/time')
+ time = require('std/time'),
+ http = require('http')
module.exports = {
compileFile: compileFile,
@@ -15,12 +16,14 @@ module.exports = {
}
function compileFile(filename, opts, callback) {
- loadCompiler().compileFile(filename, opts, callback)
+ loadCompiler().compileFile(_resolveFilename(filename), opts, callback)
}
-function listen(port, filename, opts) {
+function listen(port, filenameRaw, opts) {
if (!port) { port = 8080 }
+ var filename = _resolveFilename(filenameRaw)
+
try {
var stat = fs.statSync(filename)
} catch(e) {
@@ -51,6 +54,10 @@ function listen(port, filename, opts) {
console.log('Fun!'.magenta, 'Serving', filenameRaw.green, 'on', ('localhost:'+port).cyan, 'with these options:\n', opts)
}
+function _resolveFilename(filename) {
+ return filename[0] == '/' ? filename : path.join(process.cwd(), filename)
+}
+
function serveDevClient(req, res) {
fs.readFile(path.join(__dirname, './dev-client.html'), curry(respond, res))
}

0 comments on commit c3147c0

Please sign in to comment.