Skip to content

Commit 9ffb0cb

Browse files
committed
wip
1 parent 3d40327 commit 9ffb0cb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

scripts/purge-jsdeliver-cache.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
const { execSync } = require('node:child_process')
12
const fs = require('node:fs')
23
const path = require('node:path')
3-
44
/**
55
* Given a package name and a relative path to the dist folder -- it reads all the files and runs them through the jsdelivr cache purge API.
66
*/
@@ -13,6 +13,24 @@ const purgeJsDelivrCache = async (packageName, relativePath) => {
1313
process.exit(1)
1414
}
1515

16+
// Check if the current git HEAD has a tag containing the package name
17+
try {
18+
const tags = execSync('git tag --contains HEAD', { cwd: gitRoot })
19+
.toString()
20+
.split('\n')
21+
.filter((tag) => tag.includes(packageName))
22+
23+
if (tags.length === 0) {
24+
console.log(
25+
`No tags containing the package name "${packageName}" found on the current git HEAD. Aborting script.`
26+
)
27+
process.exit(0)
28+
}
29+
} catch (error) {
30+
console.error(`Failed to check git tags: ${error.message}`)
31+
process.exit(1)
32+
}
33+
1634
const files = fs.readdirSync(fullPath)
1735

1836
console.log(

0 commit comments

Comments
 (0)