LoginSignup
0
0

More than 5 years have passed since last update.

CakefileでCoffeScriptをwatch

Posted at

CakefileでCoffeeScriptをwatchするタスク。
色々なところから拝借したものだけど。
さくっと作ってプロジェクトで環境を共有したいときに。
(なんかそういう用のいいライブラリとかありそうだけど)

{spawn, exec} = require 'child_process'

option '-o', '--output [DIR]', 'Output directory.'
option '-t', '--target [DIR]', 'Watch target directory.'

stdout_handler = (data) ->
    console.log data.toString().trim()

build = (watch, output, target) ->
    console.log 'Watching coffee scripts'

    options = ['-c', '-o', (output || 'js'), (target || '_src/coffee')]

    if watch is true
        options[0] = '-cw'

    coffee = spawn 'coffee', options

    coffee.stdout.on 'data', stdout_handler


task 'build', 'build the project', (watch) ->
    build watch

task 'watch', 'watch for changes and rebuild', (options) ->
    build true, options.output, options.target
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0