td-octopus 0.2.6 → 0.2.7
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/package.json +1 -1
- package/src/utils/file.js +12 -1
package/package.json
CHANGED
package/src/utils/file.js
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* glob 路径匹配,支持 * 通配符
|
|
7
|
+
*/
|
|
8
|
+
function matchGlob(filePath, pattern) {
|
|
9
|
+
if (!pattern.includes('*')) {
|
|
10
|
+
return filePath.includes(pattern);
|
|
11
|
+
}
|
|
12
|
+
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
|
|
13
|
+
return regex.test(filePath);
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
/**
|
|
6
17
|
* 获取文件夹下符合要求的所有文件
|
|
7
18
|
* @function getSpecifiedFiles
|
|
@@ -18,7 +29,7 @@ function getSpecifiedFiles(dir, exclude = []) {
|
|
|
18
29
|
return files.concat(getSpecifiedFiles(name, exclude));
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
if (isFile && !_.find(exclude, p=>name
|
|
32
|
+
if (isFile && !_.find(exclude, p => matchGlob(name, p))) {
|
|
22
33
|
return files.concat(name);
|
|
23
34
|
}
|
|
24
35
|
return files;
|