Join multiple Coffeescript files into one file? (Multiple subdirectories)

前端 未结 7 1785
臣服心动
臣服心动 2020-12-31 13:19

I\'ve got a bunch of .coffee files that I need to join into one file.

I have folders set up like a rails app:

/src/controller/log_controller.coffee
/         


        
7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 14:09

    You could write a shell script or Rake task to combine them together first, then compile. Something like:

    find . -type f -name '*.coffee' -print0 | xargs -0 cat > output.coffee

    Then compile output.coffee

    Adjust the paths to your needs. Also make sure that the output.coffee file is not in the same path you're searching with find or you will get into an infinite loop.

    http://man.cx/find | http://www.rubyrake.org/tutorial/index.html

    Additionally you may be interested in these other posts on Stackoverflow concerning searching across directories:

    • How to count lines of code including sub-directories
    • Bash script to find a file in directory tree and append it to another file
    • Unix script to find all folders in the directory

提交回复
热议问题