fix: fixed remove announcement bar action (#2281)

This commit is contained in:
Shahed Nasser
2022-09-30 13:06:56 +03:00
committed by GitHub
parent 7a721e6447
commit 64ebece3b4
2 changed files with 9 additions and 6 deletions

View File

@@ -15,13 +15,19 @@ async function main () {
if (shouldExpire) {
//check if the file was last updated 6 days ago
try {
const fileStat = fs.statSync(path.join(__dirname, '..', 'www', 'docs', 'announcement.json'));
if (dateDiffInDays(fileStat.mtime, new Date()) < 6) {
const commitResponse = await octokit.request('GET /repos/{owner}/{repo}/commits', {
owner: 'medusajs',
repo: 'medusa',
path: path.join('www', 'docs', 'announcement.json'),
per_page: 1
})
if (commitResponse.data.length && dateDiffInDays(commitResponse.data[0].commit.committer.date, new Date()) < 6) {
console.log("File was edited less than 6 days ago. Expiry canceled.");
return;
}
} catch (e) {
//file doesn't exist, continue
//continue as if file doesn't exist
}
} else {
//retrieve the latest release