One bad manifest shouldn't break everything.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3225 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2016-05-01 13:25:00 +00:00
parent 395495fa12
commit c910a5b8e7

View File

@ -189,14 +189,23 @@ function badName(name) {
} }
function getManifest(fileName) { function getManifest(fileName) {
var manifest = []; let manifest = [];
var lines = File.readFile(fileName).split("\n").map(x => x.trimRight()); let lines = File.readFile(fileName).split("\n").map(x => x.trimRight());
for (var i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {
if (lines[i].substring(0, 4) == "//! ") { if (lines[i].substring(0, 4) == "//! ") {
manifest.push(lines[i].substring(4)); manifest.push(lines[i].substring(4));
} }
} }
return manifest.length ? JSON.parse(manifest.join("\n")) : null; let result;
try {
if (manifest.length) {
result = JSON.parse(manifest.join("\n"));
}
} catch (error) {
print("ERROR: getManifest(" + fileName + "): ", error);
// Oh well. No manifest.
}
return result;
} }
function packageNameToPath(name) { function packageNameToPath(name) {