diff --git a/lib/coffee-script/command.js b/lib/coffee-script/command.js index 2f197660..199754ee 100644 --- a/lib/coffee-script/command.js +++ b/lib/coffee-script/command.js @@ -44,6 +44,9 @@ if (opts.version) return version(); if (opts.require) loadRequires(); if (opts.interactive) return require('./repl'); + if (opts.watch && !fs.watch) { + printWarn("The --watch feature depends on Node v0.6.0+. You are running " + process.version + "."); + } if (opts.stdio) return compileStdio(); if (opts.eval) return compileScript(null, sources[0]); if (!sources.length) return require('./repl'); @@ -196,6 +199,7 @@ }; watch = function(source, base) { + if (!fs.watch) return; return fs.stat(source, function(err, prevStats) { var callback, watcher; if (err) throw err; diff --git a/src/command.coffee b/src/command.coffee index 27efa13d..277267e6 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -62,6 +62,9 @@ exports.run = -> return version() if opts.version loadRequires() if opts.require return require './repl' if opts.interactive + if opts.watch and !fs.watch + printWarn "The --watch feature depends on Node v0.6.0+. You are running \ +#{process.version}." return compileStdio() if opts.stdio return compileScript null, sources[0] if opts.eval return require './repl' unless sources.length @@ -172,6 +175,7 @@ loadRequires = -> # time the file is updated. May be used in combination with other options, # such as `--lint` or `--print`. watch = (source, base) -> + return unless fs.watch fs.stat source, (err, prevStats)-> throw err if err watcher = fs.watch source, callback = (event) ->