javascript - Monitoring sub-task for grunt-contrib-watch -


i have following gruntfile.coffee. monitoring watch task shown below see file changes , compile changed file coffee-script.

# watch task watch:  coffee:   files: ['client/**/*.coffee','server/**/*/.coffee']   options:    nospawn: true    livereload: true  # watch changed files grunt.event.on 'watch', (action, filepath) ->  cwd = 'client/'  filepath = filepath.replace(cwd,'')  grunt.config.set('coffee',   changed:    expand: true    cwd: cwd    src: filepath    dest: 'client-dist/'    ext: '.js'  )  grunt.task.run('coffee:changed') 

however, add watch task copy files on not coffee files. how monitor these changes?

i thought of doing

# watch copy task grunt.event.on 'watch:copy', (action,filepath) -> ... # watch coffee task grunt.event.on 'watch:coffee', (action,filepath) -> ... 

but doesn't seem work. ideas?

my solution - gets job done isn't pretty. welcome better answers

basically, match path of incoming file
if .coffee run coffee compile task
if .* run copy task

# watch changed files grunt.event.on 'watch', (action, filepath) ->   # determine server or client folder  path = if filepath.indexof('client') isnt -1 'client' else 'server'  cwd = "#{path}/"  filepath = filepath.replace(cwd,'')           # minimatch coffee files  if minimatch filepath, '**/*.coffee'   # compile changed file   grunt.config.set('coffee',    changed:     expand: true     cwd: cwd     src: filepath     dest: "#{path}-dist/"     ext: '.js'   )   grunt.task.run('coffee:changed')     # minimatch others  if minimatch filepath, '**/*.!(coffee)'   # copy changed file   grunt.config.set('copy',    changed:     files: [      expand: true      cwd: cwd      src: filepath      dest: "#{path}-dist/"                           ]   )   grunt.task.run("copy:changed") 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -