Reputation: 121
I am currently writing a string of text to the console for testing reasons, as below:
console.log JSON.stringify @classification
How do I write this to a text file in coffeescript?
Cheers
James
In node.js - and I want to write to a filename of my choosing - not a default log file.
Upvotes: 2
Views: 3673
Reputation: 146124
fs = require "fs"
fs.writeFile "classification.json", JSON.stringify(@classification), (error) ->
console.error("Error writing file", error) if error
Upvotes: 5