How to read mobile-config.js file from a server file?


#1

Hi, I have a meteor app (http://99folks.com) and I’d like to render the current app version in a template, but I didn’t find a way to read data from mobile-config.js file, for while I just repeated the app version into a settings.json, but it is not a good idea keeping two files with the app version. Does anybody can help me?


#2

You can use the npm module fs.

var fs = Npm.require("fs");
var root = process.env.PWD;
fs.readFile(root + '/mobile-config.js', "utf8", function(err, data) {
	if (err) throw err;
	console.log(data);
});

data has the content of the file encoded as UTF-8.


#3

Thanks a lot! This code works fine!