Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Do not spawn a compiler for every file. #21

Merged
merged 1 commit into from

2 participants

@rybesh

I was getting an EMFILE (too many open files) with the current approach of spawning a coffee process for every file (see below). This changes the Cakefile to compile each source directory all at once.

child_process.js:444
    throw errnoException(errno, 'spawn');
    ^
Error: spawn EMFILE
    at errnoException (child_process.js:481:11)
    at ChildProcess.spawn (child_process.js:444:11)
    at child_process.js:342:9
    at Object.execFile (child_process.js:252:15)
    at child_process.js:220:18
    at /Users/ryanshaw/Code/noflo/Cakefile:29:12
    at Object.oncomplete (/Users/ryanshaw/Code/noflo/Cakefile:45:20)
@bergie bergie merged commit 49a538d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 22, 2012
  1. @rybesh
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 12 deletions.
  1. +2 −12 Cakefile
View
14 Cakefile
@@ -10,20 +10,10 @@ sh = (command) -> (k) ->
console.log serr if serr
do k
-buildFile = (parentPath, dir, file) ->
- exec "coffee -o #{parentPath}/#{dir} -c #{parentPath}/src/#{dir}/#{file}", (err, stdout, stderr) ->
- console.log stderr if stderr
-
buildDir = (path) ->
console.log "Compiling CoffeeScript from 'src/#{path}' to '#{path}"
-
- fs.readdir "#{__dirname}/src/#{path}", (err, files) ->
- return console.log err if err
- files.forEach (file) ->
- fs.stat "#{__dirname}/src/#{path}/#{file}", (err, stats) ->
- return buildFile __dirname, path, file if file.indexOf(".coffee") isnt -1
- return unless stats.isDirectory()
- buildDir "#{path}/#{file}"
+ exec "coffee -c -o #{__dirname}/#{path} #{__dirname}/src/#{path}", (err, stdout, stderr) ->
+ console.log stderr if stderr
task 'build', 'transpile CoffeeScript sources to JavaScript', ->
buildDir "lib"
Something went wrong with that request. Please try again.