Can't write with fs


#1

Hi

I’m trying to write with fs in a package I’m making. The code I have is this

fs = Npm.require('fs');

steamBot.on('sentry', function(data) {
	console.log('Got sentry')
	fs.writeFileSync('sentry', data);
});

I can see the console.log firing but there is no file to be found.

max@max:~/dev/steamtest$ find . -name sentry
max@max:~/dev/steamtest$ 

How can I use this module in meteor?


#2

The path you’re writing to will be relative to the compiled app code. You should change the path to be somewhere where you can find the file.


#3

Any suggestions? Does Meteor have something like Meteor.rootPath()?


#4

What kind of package are you writing that requires writing things in the file system? Is what you’re doing more suitable as a build plugin? http://docs.meteor.com/#/full/Package-registerBuildPlugin


#5

No, I’m just saving some data. I think it’s a binary file? Not sure. It’s used when authing to Steam.

https://github.com/seishun/node-steam/blob/master/lib/handlers/user.js#L224-L233