Commit 1e72717d authored by Efthymia Bika's avatar Efthymia Bika

Init templates file when content is 'undefined'

parent dc97fdc4
......@@ -159,8 +159,9 @@ function write_conf_file(filename, data) {
function write_file_if_empty(filename, data) {
var file = path.join(get_user_home(), BAAS_HOME_DIR, filename);
fs.stat(file, function(err, stats) {
if(err || (stats && stats.size == 0)) {
fs.readFile(file, "utf8", function(err, contents) {
if(err || contents.length == 0 ||
contents.toString().trim() == "undefined") {
fs.writeFile(file, JSON.stringify(data, null, 2), function(error) {
if(error) return console.error(error);
console.log("Successfully initialized " + file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment