Created
September 17, 2012 06:04
-
-
Save jonsherrard/3735784 to your computer and use it in GitHub Desktop.
Cakefile with delay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Double check file structure before use | |
task 'build:coffee', 'build src/client.js file from source files', (options) -> | |
files = content = [] | |
finished = {} | |
fs.readFile 'src/client/coffee/base.coffee', 'utf8', (err, contents) -> | |
content.push contents | |
for dir in ['views', 'collections', 'models'] then do (dir) -> | |
delay = (ms, func) -> setTimeout func, ms | |
if dir is 'models' | |
duration = 20 | |
if dir is 'views' | |
duration = 0 | |
if dir is 'collections' | |
duration = 50 | |
delay duration, -> | |
exec 'find src/client/coffee/' + dir, (err, stdout, stderr) -> | |
files = stdout.split '\n' | |
console.log dir | |
console.log files | |
remain = files.length | |
for file, i in files then do (file, i) -> | |
fs.readFile file, 'utf8', (err, contents) -> | |
content.push contents | |
if --remain is 0 | |
finished[dir] = true | |
console.log dir + ' done!' | |
if finished.models and finished.collections and finished.views then finish() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment