mailtrain/lib/file-helpers.js

33 lines
662 B
JavaScript
Raw Normal View History

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
}
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) {
return getReportFileBase(report) + '.out';
2017-04-25 22:49:31 +00:00
}
function getReportOutputFile(report) {
return getReportFileBase(report) + '.err';
2017-04-25 22:49:31 +00:00
}
module.exports = {
getReportContentFile,
getReportOutputFile,
nameToFileName
};