Skip to content

Commit 90fecd3

Browse files
committed
Purge version-less URLs when "latest" tag is used
1 parent 2d45078 commit 90fecd3

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

scripts/purge-cache.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,24 @@ getFiles(packageName, version)
3737
)
3838
);
3939

40+
let urls = files.map(
41+
file => `https://unpkg.com/${packageName}@${version}${file.path}`
42+
);
43+
44+
if (version === 'latest') {
45+
// Purge the URL w/out the "@latest" too.
46+
urls = urls.concat(
47+
files.map(file => `https://unpkg.com/${packageName}${file.path}`)
48+
);
49+
}
50+
4051
return getZone('unpkg.com').then(zone => {
4152
let promise = Promise.resolve();
4253

43-
groupBy(files, 30).forEach(group => {
54+
groupBy(urls, 30).forEach(group => {
4455
promise = promise.then(() => {
45-
const urls = group.map(
46-
file => `https://unpkg.com/${packageName}@${version}${file.path}`
47-
);
48-
49-
return purgeFiles(zone.id, urls).then(data => {
50-
group.forEach(file =>
51-
console.log(chalk.green(`Purged ${file.path}`))
52-
);
56+
return purgeFiles(zone.id, group).then(data => {
57+
group.forEach(url => console.log(chalk.green(`Purged ${url}`)));
5358
});
5459
});
5560
});

0 commit comments

Comments
 (0)