Permalink
Browse files

added watch command

  • Loading branch information...
1 parent cfc2ca9 commit 5c89ed7fb677acf692d44d7df58209723934cb16 @chrisfjones chrisfjones committed Jan 3, 2013
Showing with 139 additions and 40 deletions.
  1. +59 −6 lib/cli.js
  2. +44 −7 lib/index.js
  3. +0 −6 lib/starman.js
  4. +0 −9 lib/watch.js
  5. +1 −1 package.json
  6. +3 −5 src/cli.iced
  7. +32 −3 src/index.iced
  8. 0 src/starman.iced
  9. +0 −3 src/watch.iced
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -23,7 +23,7 @@
"commander" : "1.1.1",
"connect":"2.7.0",
"underscore":"1.4.2",
- "walk":"2.2.1",
+ "watch":"0.5.1",
"fs.extra":"1.2.0",
"colors":"0.6.0-1"
},
View
@@ -1,13 +1,10 @@
program = require 'commander'
-colors = require 'colors'
+colors = require 'colors'
starman = require './index'
-
-todoString = 'todo: '.blue
-star = '\u2606'.red
+star = '\u2606'.red
program
.version('0.0.1')
- .option('-v, --verbose', 'be chatty.')
program
.command('init')
@@ -65,6 +62,7 @@ program
starman.build()
starman.watch()
starman.serve port
+ await setTimeout defer(), 1000
starman.open port unless options.dontOpen
)
View
@@ -1,9 +1,13 @@
+watch = require 'watch'
+fs = require 'fs'
+{exec} = require 'child_process'
+_ = require 'underscore'
+colors = require 'colors'
+star = '\u2606'.red
+
module.exports.init = require './init'
module.exports.serve = require './serve'
module.exports.build = require './build'
-module.exports.watch = require './watch'
-
-{exec} = require 'child_process'
module.exports.clean = (callback) ->
await exec 'rm -rf release/', defer()
@@ -13,3 +17,28 @@ module.exports.clean = (callback) ->
module.exports.open = (port) ->
await exec "open http://localhost:#{port}", defer(err)
console.error err if err?
+
+module.exports.watch = (callback) ->
+ buildWrapper = ->
+ process.stdout.write "#{star} "
+ module.exports.build()
+
+ lazyBuild = _.debounce buildWrapper, 500
+
+ fileChangeCallback = (f, curr, prev) ->
+ if not curr and not prev
+ return
+ lazyBuild()
+
+ opts =
+ ignoreDotFiles : true
+ filter : (f) -> not f.match(/~$/)?
+ persistent: true
+ interval: 511
+
+ dirs = ['pages', 'src', 'static', 'scss']
+ watch.watchTree dir, opts, fileChangeCallback for dir in dirs
+ fs.watchFile 'layout.html.coffee', opts, lazyBuild
+
+ console.log 'watching for changes...'
+ callback?()
View
No changes.
View
@@ -1,3 +0,0 @@
-module.exports = (callback) ->
- console.log 'todo: watch'
- callback?()

0 comments on commit 5c89ed7

Please sign in to comment.