Skip to content

Commit

Permalink
Merge pull request #99 from Raistlfiren/hotfix-output-release
Browse files Browse the repository at this point in the history
Fixed latest client issue.
  • Loading branch information
Raistlfiren authored Jun 12, 2017
2 parents 145faa9 + a03f981 commit 3d56840
Showing 1 changed file with 36 additions and 27 deletions.
63 changes: 36 additions & 27 deletions scripts/getLatestClientRelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,48 @@ gh.getRepo('faforever', 'client').getRelease('latest', function(err, release) {
};

//Write to file
fs.writeFile("link.json", JSON.stringify(data), function(error) {
if (error) {
console.log(error);
fs.writeFile("link.json", JSON.stringify(data), function(err) {
if (err) {
console.log(err);
verifyOutput();
} else {
console.log(date + ' - Link file created successfully for latest client links.');
}
});
}
});

}
}
);

//Try to read the file after creating it
fs.readFile('link.json', 'utf8', function (err, data) {
try {
//Must of parsed out properly
clientLink = JSON.parse(data);
} catch (e) {
//Must not have...
console.log(date + ' - Link file incorrectly made. Data was - ' + data);
//Write default values to file...
data = {
client_link: 'https://github.com/FAForever/client/releases',
downlords_faf_client_link: 'https://github.com/FAForever/downlords-faf-client/releases'
};
fs.writeFile("link.json", JSON.stringify(data), function(error) {
if (error) {
console.log(error);
} else {
console.log(date + ' - Link file verified.');
console.log(err);
verifyOutput();
}
});

} else {
console.log(err);
verifyOutput();
}
});

function verifyOutput()
{
//Try to read the file after creating it
fs.readFile('link.json', 'utf8', function (err, data) {
try {
//Must of parsed out properly
clientLink = JSON.parse(data);
} catch (e) {
//Must not have...
console.log(date + ' - Link file incorrectly made. Data was - ' + data);
//Write default values to file...
data = {
client_link: 'https://github.com/FAForever/client/releases',
downlords_faf_client_link: 'https://github.com/FAForever/downlords-faf-client/releases'
};
fs.writeFile("link.json", JSON.stringify(data), function(error) {
if (error) {
console.log(error);
} else {
console.log(date + ' - Link file verified.');
}
});
}
});
}

0 comments on commit 3d56840

Please sign in to comment.