|
|
@ -2,18 +2,33 @@ const fs = require('fs'); |
|
|
|
|
|
|
|
const sql = require('../utils/sql'); |
|
|
|
|
|
|
|
var stream = fs.createWriteStream("../sitemap.txt"); |
|
|
|
|
|
|
|
stream.once('open', function(fd) |
|
|
|
module.exports= |
|
|
|
{ |
|
|
|
sql.getSiteMap().then(function(result) |
|
|
|
{ |
|
|
|
stream.write(result); |
|
|
|
}).then(function() |
|
|
|
{ |
|
|
|
stream.end(); |
|
|
|
}).catch(function(err) |
|
|
|
|
|
|
|
main: function() |
|
|
|
{ |
|
|
|
console.log(err); |
|
|
|
}); |
|
|
|
}); |
|
|
|
sql.getSiteMap().then(function(result) |
|
|
|
{ |
|
|
|
var buf = Buffer.from(result, 'utf8'); |
|
|
|
|
|
|
|
var path = '../sitemap.txt'; |
|
|
|
fs.open(path, 'w', function(error, fd) |
|
|
|
{ |
|
|
|
if(error) |
|
|
|
throw 'could not open file: ' + error; |
|
|
|
|
|
|
|
fs.write(fd, buf, 0, buf.length, null, function(err) |
|
|
|
{ |
|
|
|
if(err) |
|
|
|
throw "error writing file: " + err; |
|
|
|
|
|
|
|
fs.close(fd, function() |
|
|
|
{ |
|
|
|
console.log("Updated Sitemap"); |
|
|
|
}) |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|