2012-12-11 2 views
1

은 현재 내가 설정을 같은 커피 스크립트, 옥, 스타일러스를보고 컴파일하는 cake 작업이 : 이제개발하면서 Cakefile에서 파일을보고/복사 할 수 있습니까?

task "startdev", "Starts server with nodemon and watch files for changes", -> 
    # start nodemon server 
    nodemon = spawn procExec("nodemon"), ["server.coffee"] 
    processOutput nodemon 

    # watch and compile CoffeeScript 
    coffee = spawn procExec("coffee"), ["-o", "public/js/app", "-cw", "client/coffee"] 
    processOutput coffee 

    # watch and compile Stylus 
    stylus = spawn procExec("stylus"), ["client/stylus/styles.styl", "-I", "public/css/","-l", "-w", "-u", "./node_modules/nib", "-o", "public/css/app"] 
    processOutput stylus 

    # watch and compile jade 
    jade = spawn procExec("jade"), ["client/jade/index.jade", "--out", "public"] 
    processOutput jade 

을, 나는 폴더에있는 파일 변경에 대한보고 싶은과는 다른 폴더 (일명 동기화 폴더에 복사, src에서 public까지 파일 복사). 내가 어떻게 할 수 있니? 나는 그 솔루션이 노드/JS에만 국한되지 않는다면 좋다고 생각한다. 제대로 작동하도록하기 위해 전체 묶음과 많은 설정을 다운로드하지 않아도된다.

일부 연구를 마친 후 아마도 jake과 같은 빌드를 사용해야할까요? 하지만이 개 폴더

를 동기화하는 데 사용할 어떻게

답변

0

이 할 시계를 사용할 수 있습니다 :

watch = require 'watch' 

task 'watch', 'watches for file and copy/compiles them', -> 
    # watch file changes 
    watch.watchTree 'src', (f, curr, prev) -> 
    return if typeof f is "object" && prev is null && curr is null 
    return if f.match(/\.(coffee)$/) 
    dest = 'lib' + f[3..] 
    if curr.nlink is 0 
     fs.unlinkSync dest if fs.existsSync dest 
     log "removed " + dest 
    else 
     oldFile = fs.createReadStream f 
     newFile = fs.createWriteStream dest 
     oldFile.pipe newFile 
     log "copied " + f + ' to ' + dest 
    log 'Watching to copy files', green 
    # watch_coffee 
    ... 
관련 문제