@seayoo-web/finder 2.0.14 → 2.0.15

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.
package/dist/index.js CHANGED
@@ -41,13 +41,21 @@ function getAllFiles(dir, ignores = []) {
41
41
  function isIgnoreFile(filePath, ignores) {
42
42
  const filename = basename(filePath);
43
43
  const dirs = normalize(filePath).split(sep);
44
- return ignores.some((name) => {
45
- if (name.endsWith("/") && name !== "/") {
46
- return dirs.includes(name.slice(0, -1));
44
+ return ignores.some((pattern) => {
45
+ if (pattern.endsWith("/")) {
46
+ return pattern.includes("*") ? dirs.some((dir) => getRegexp(pattern.slice(0, -1)).test(dir)) : dirs.includes(pattern.slice(0, -1));
47
47
  }
48
- return filename === name;
48
+ return pattern.includes("*") ? getRegexp(pattern).test(filename) : filename === pattern;
49
49
  });
50
50
  }
51
+ const pathRegCache = {};
52
+ const getRegexp = function(path2) {
53
+ if (path2 && pathRegCache[path2]) {
54
+ return pathRegCache[path2];
55
+ }
56
+ const fixRegStr = path2.replace(/([\\(){}\[\]\^\$\+\-\?\.|])/g, "\\$1").replace(/\*{1,}/g, ".*");
57
+ return pathRegCache[path2] = new RegExp("^" + fixRegStr + "$");
58
+ };
51
59
  function pure(url) {
52
60
  return url.replace(/(?:^https?:\/\/|\/*$)/gi, "");
53
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/finder",
3
- "version": "2.0.14",
3
+ "version": "2.0.15",
4
4
  "description": "agent for web finder",
5
5
  "type": "module",
6
6
  "source": "index.ts",
@@ -3,7 +3,11 @@ import "colors";
3
3
  export declare function finderDeploy(option: {
4
4
  /** 需要推送的代码目录 */
5
5
  dist: string;
6
- /** 忽略部署的文件,如果是目录则需要以 / 结尾。暂不支持模糊匹配 */
6
+ /**
7
+ * 忽略部署的文件,如果是目录则需要以 / 结尾,支持 * 占位符模糊匹配。
8
+ *
9
+ * 匹配时仅针对单一目录和文件名进行检查,不跨目录检查
10
+ */
7
11
  ignoreFiles?: string[];
8
12
  /** 部署的目标地址 */
9
13
  deployTo: string | string[];