diff --git a/lib/command.js b/lib/command.js index 29543021..d5d0d3f3 100644 --- a/lib/command.js +++ b/lib/command.js @@ -153,9 +153,6 @@ if (curr.mtime.getTime() === prev.mtime.getTime()) { return null; } - if (options.compile) { - puts(("Compiled " + source)); - } return fs.readFile(source, function(err, code) { return compileScript(source, code.toString(), base); }); @@ -172,7 +169,11 @@ dir = options.output ? path.join(options.output, baseDir) : srcDir; jsPath = path.join(dir, filename); compile = function() { - return fs.writeFile(jsPath, js); + return fs.writeFile(jsPath, js, function(err) { + if (options.compile && options.watch) { + return puts(("Compiled " + source)); + } + }); }; return path.exists(dir, function(exists) { if (exists) { diff --git a/lib/nodes.js b/lib/nodes.js index 28111258..a33f636c 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -255,7 +255,6 @@ return this; } this.expressions[idx] = last.makeReturn(); - // unless last.containsPureStatement() return this; }; // An **Expressions** is the only node that can serve as the root. diff --git a/src/command.coffee b/src/command.coffee index 36769f8b..b17a79b7 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -114,7 +114,6 @@ compileStdio: -> watch: (source, base) -> fs.watchFile source, {persistent: true, interval: 500}, (curr, prev) -> return if curr.mtime.getTime() is prev.mtime.getTime() - puts "Compiled $source" if options.compile fs.readFile source, (err, code) -> compileScript(source, code.toString(), base) # Write out a JavaScript source file with the compiled code. By default, files @@ -122,11 +121,13 @@ watch: (source, base) -> # directory can be customized with `--output`. writeJs: (source, js, base) -> filename: path.basename(source, path.extname(source)) + '.js' - srcDir: path.dirname source - baseDir: srcDir.substring base.length + srcDir: path.dirname source + baseDir: srcDir.substring base.length dir: if options.output then path.join options.output, baseDir else srcDir - jsPath: path.join dir, filename - compile: -> fs.writeFile jsPath, js + jsPath: path.join dir, filename + compile: -> + fs.writeFile jsPath, js, (err) -> + puts "Compiled $source" if options.compile and options.watch path.exists dir, (exists) -> if exists then compile() else exec "mkdir -p $dir", compile