diff options
| author | Jez Ng | 2012-08-07 21:17:05 -0700 | 
|---|---|---|
| committer | Jez Ng | 2012-08-07 21:17:05 -0700 | 
| commit | a77dbd42dae9984d30f3b1f63ef8240a9e927fc9 (patch) | |
| tree | 033560a4b938f90903678c35633bdea3a256b70c | |
| parent | 9d17e9c0bca61b67f3eae0f220acc3bd5ce439d1 (diff) | |
| parent | 57bc52a4fc7b64eb88415fba2e6dd95f499c3b6a (diff) | |
| download | vimium-a77dbd42dae9984d30f3b1f63ef8240a9e927fc9.tar.bz2 | |
Merge pull request #611 from liesen/cake-clean-keep-main-js
Keep main.js when doing `cake clean`.
| -rw-r--r-- | Cakefile | 16 | 
1 files changed, 13 insertions, 3 deletions
| @@ -1,4 +1,5 @@  fs = require "fs" +path = require "path"  {spawn, exec} = require "child_process"  spawn_with_opts = (proc_name, opts) -> @@ -15,9 +16,18 @@ task "build", "compile all coffeescript files to javascript", ->  task "clean", "removes any js files which were compiled from coffeescript", ->    src_directories.forEach (directory) -> -    files = fs.readdirSync(directory).filter((filename) -> filename.indexOf(".js") > 0) -    files = files.map((filename) -> "#{directory}/#{filename}") -    files.forEach((file) -> fs.unlinkSync file if fs.statSync(file).isFile()) +    fs.readdirSync(directory).forEach (filename) -> +      return unless (path.extname filename) == ".js" +      filepath = path.join directory, filename +      return unless (fs.statSync filepath).isFile() + +      # Check if there exists a corresponding .coffee file +      try +        coffeeFile = fs.statSync path.join directory, "#{path.basename filepath, ".js"}.coffee" +      catch _ +        return + +      fs.unlinkSync filepath if coffeeFile.isFile()  task "autobuild", "continually rebuild coffeescript files using coffee --watch", ->    coffee = spawn "coffee", ["-cw"].concat(src_directories) | 
