aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJez Ng2012-08-07 21:17:05 -0700
committerJez Ng2012-08-07 21:17:05 -0700
commita77dbd42dae9984d30f3b1f63ef8240a9e927fc9 (patch)
tree033560a4b938f90903678c35633bdea3a256b70c
parent9d17e9c0bca61b67f3eae0f220acc3bd5ce439d1 (diff)
parent57bc52a4fc7b64eb88415fba2e6dd95f499c3b6a (diff)
downloadvimium-a77dbd42dae9984d30f3b1f63ef8240a9e927fc9.tar.bz2
Merge pull request #611 from liesen/cake-clean-keep-main-js
Keep main.js when doing `cake clean`.
-rw-r--r--Cakefile16
1 files changed, 13 insertions, 3 deletions
diff --git a/Cakefile b/Cakefile
index 0a45abac..e1434d24 100644
--- a/Cakefile
+++ b/Cakefile
@@ -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)