Code: Select all
main.js
Code: Select all
module.exports = {updateLogs}
Code: Select all
//main.js
const d = new Date();
const logName = "fooBar";
process.env.LOGFILE = logName + "-" + d.getDay() + "-" + d.getMonth() + "-" + d.getFullYear() + ".json";
createLogs(logName);
// Running tests on other files...
< /code>
Helper-funktions.js
//If I uncomment the below it works, but file name is hard coded.
//process.env.LOGFILE = "customLogs.json";
//Create log file when scripts are first run
const createLogs = (logName) => {
exec('git branch --show-current', (err, stdout, stderr) => {
if (err) {
console.log("Error getting git branch:" + stderr);
}
const startTime = ((Date()).toLocaleString()).split('GMT')[0];
const branchName = stdout ? stdout.replace(/(\r\n|\n|\r)/gm,"") : "no-branch";
let repObjString = `{"details":{"name": "${logName}","time": "${startTime}","branch": "${branchName}"},"report":{}}`;
const logFileName = `logs/${process.env.LOGFILE}`; // {
const logName = `logs/${process.env.LOGFILE}`; //