-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite-report.js
33 lines (26 loc) · 1.05 KB
/
write-report.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var fs = require('fs');
var path = require('path');
module.exports = {
writeReport: function(resourcesExposed, reportingDirectory, mockDirectory) {
// used to write the report in a specific file
var generatedDataFileName = "GeneratedData.js";
var angularFactorytemplate = "apiReport.factory('GeneratedData', function(){return {getData: function(){return $$$$;},getReadme: function(){return &&&&;}}});";
var globalReadmeContent = getGlobalReadme();
var fileContent = angularFactorytemplate.replace("$$$$", JSON.stringify(resourcesExposed));
var fileContent = fileContent.replace("&&&&", JSON.stringify(globalReadmeContent));
fs.writeFileSync(
path.join(__dirname,reportingDirectory) + "\\app\\services\\" + generatedDataFileName,
fileContent,
"utf8");
function getGlobalReadme(){
// try to fetch README.md
try {
return readmeContent = fs.readFileSync(path.join(mockDirectory, "README.md"), "utf8");
//catch exceptions
} catch (e) {
// README.md not found
console.error("Global README.md not found");
}
}
}
};