I try to read local file with coffescript and node.js. My code:
fs = require('fs')
foo = () ->
return (fs.readFileSync config, 'utf8')
File is not empty. But when i call foo i got empty string. How can i read file to string correctly?
Thank you
It's difficult to tell what you're doing wrong as you only show part of your program, but here is a demonstration of a similar program working.
test.txt:
testing
test.coffee:
fs = require 'fs'
config = 'test.txt'
foo = ->
fs.readFileSync config, 'utf8'
console.log foo()
Output:
$ coffee test.coffee
testing