swpp-backends 0.0.8-alpha → 0.0.9-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,13 +41,15 @@ const Utils_1 = require("./Utils");
41
41
  * @param root 根目录
42
42
  * @param cb 回调函数(接收的参数是文件的相对路径)
43
43
  */
44
- function eachAllFile(root, cb) {
44
+ async function eachAllFile(root, cb) {
45
45
  const stats = fs_1.default.statSync(root);
46
46
  if (stats.isFile())
47
- cb(root);
47
+ await cb(root);
48
48
  else {
49
49
  const files = fs_1.default.readdirSync(root);
50
- files.forEach(it => eachAllFile(path_1.default.join(root, it), cb));
50
+ for (let it of files) {
51
+ await eachAllFile(path_1.default.join(root, it), cb);
52
+ }
51
53
  }
52
54
  }
53
55
  /**
@@ -165,7 +167,7 @@ exports.readMergeVersionMap = readMergeVersionMap;
165
167
  */
166
168
  async function buildVersionJson(protocol, domain, root) {
167
169
  const list = {};
168
- eachAllFile(root, async (path) => {
170
+ await eachAllFile(root, async (path) => {
169
171
  const endIndex = path.length - (path.endsWith('/index.html') ? 10 : 0);
170
172
  const url = new URL(protocol + path_1.default.join(domain, path.substring(root.length, endIndex)));
171
173
  const pathname = url.pathname;
@@ -254,7 +256,8 @@ async function eachAllLinkInUrl(domain, url, result, event) {
254
256
  const pathname = new URL(url).pathname;
255
257
  let content;
256
258
  const nextEvent = (it) => {
257
- result[url].push(it);
259
+ if (stable)
260
+ result[url].push(it);
258
261
  };
259
262
  const update = () => {
260
263
  if (stable)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swpp-backends",
3
- "version": "0.0.8-alpha",
3
+ "version": "0.0.9-alpha",
4
4
  "main": "dist/index.js",
5
5
  "typings": "types/index.d.ts",
6
6
  "description": "Generate a powerful ServiceWorker for your website.",