Search code examples
javascriptcoffeescriptreferenceerrorcakefile

Cakefile not seeing JS functions


I'm writing a Cakefile that defines a task called build where the following line appears:

coffee.stderr.on 'data', (data) ->
    process.stderr.write.data.toString()

When I run the task with cake build, it throws a ReferenceError saying that the function toString is undefined.

I've tried repairing the Node installation, and re-installing CoffeeScript with npm.


Solution

  • I believe you want

    process.stderr.write data.toString()
    

    You've got an extra . in there.

    The way you've written it is trying to call toString() on the data property of the write function. You're probably getting an error like Cannot call method 'toString' of undefined.