Skip to content

Commit

Permalink
feat: purge cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
theajack committed Mar 31, 2022
1 parent 6f5a07f commit dfebfad
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
36 changes: 36 additions & 0 deletions helper/purge-cdn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const https = require('https');

function main () {
const list = [
'cnchar',
'cnchar-order', 'cnchar-poly', 'cnchar-trad', 'cnchar-draw', 'cnchar-idiom', 'cnchar-xhy', 'cnchar-radical',
'cnchar-all', 'hanzi-util', 'hanzi-util-base'
];

const getFileName = (name) => {
if (name === 'hanzi-util-base') {
return 'hanzi.base';
}
return name.replace(/-/g, '.');
};

let num = 0;
const checkFinish = (name) => {
num ++;
console.log(`${name} done.(${num}/${list.length})`);
if (num >= list.length) {
console.log('Finished.');
}
};

for (let i = 0; i < list.length; i++) {
const name = list[i];

https.get(`https://purge.jsdelivr.net/npm/${name}/${getFileName(name)}.min.js`, () => {
checkFinish(name);
});
}
}

main();

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"test": "node local_test npm",
"jest": "jest",
"dev:docs": "vuepress dev vuepress",
"build:docs": "vuepress build vuepress && node ./helper/build-docs.js"
"build:docs": "vuepress build vuepress && node ./helper/build-docs.js",
"purge": "node ./helper/purge-cdn.js"
},
"devDependencies": {
"@babel/core": "^7.5.5",
Expand Down

0 comments on commit dfebfad

Please sign in to comment.