2017-04-25 22:49:31 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
function nameToFileName(name) {
|
|
|
|
return name.
|
2017-06-15 19:26:35 +00:00
|
|
|
trim().
|
|
|
|
toLowerCase().
|
|
|
|
replace(/[ .+/]/g, '-').
|
|
|
|
replace(/[^a-z0-9\-_]/gi, '').
|
|
|
|
replace(/--*/g, '-');
|
2017-04-25 22:49:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-27 20:35:53 +00:00
|
|
|
function getReportFileBase(report) {
|
2017-04-25 22:49:31 +00:00
|
|
|
return path.join(__dirname, '..', 'protected', 'reports', report.id + '-' + nameToFileName(report.name));
|
|
|
|
}
|
|
|
|
|
|
|
|
function getReportContentFile(report) {
|
2017-04-27 20:35:53 +00:00
|
|
|
return getReportFileBase(report) + '.out';
|
2017-04-25 22:49:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getReportOutputFile(report) {
|
2017-04-27 20:35:53 +00:00
|
|
|
return getReportFileBase(report) + '.err';
|
2017-04-25 22:49:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getReportContentFile,
|
|
|
|
getReportOutputFile,
|
|
|
|
nameToFileName
|
|
|
|
};
|