@itwin/build-tools 3.5.0-dev.25 → 3.5.0-dev.26

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.
@@ -13,3 +13,27 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
13
13
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+
17
+ ## [recursive-readdir](https://github.com/jergason/recursive-readdir)
18
+
19
+ The MIT License (MIT)
20
+
21
+ Copyright (c) \<year> \<copyright holders>
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in
31
+ all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
39
+ THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/build-tools",
3
- "version": "3.5.0-dev.25",
3
+ "version": "3.5.0-dev.26",
4
4
  "description": "Bentley build tools",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,6 @@
28
28
  "glob": "^7.1.2",
29
29
  "mocha": "^10.0.0",
30
30
  "mocha-junit-reporter": "^2.0.2",
31
- "recursive-readdir": "^2.2.2",
32
31
  "rimraf": "^3.0.2",
33
32
  "tree-kill": "^1.2.0",
34
33
  "typedoc": "^0.22.11",
@@ -38,7 +37,7 @@
38
37
  "yargs": "^17.4.0"
39
38
  },
40
39
  "devDependencies": {
41
- "@itwin/eslint-plugin": "3.5.0-dev.25",
40
+ "@itwin/eslint-plugin": "3.5.0-dev.26",
42
41
  "@types/node": "16.11.59",
43
42
  "eslint": "^7.11.0"
44
43
  },
@@ -8,7 +8,7 @@ const argv = require("yargs").argv;
8
8
  const path = require("path");
9
9
  const paths = require("./config/paths");
10
10
  const fs = require("fs-extra");
11
- const readDirectory = require("recursive-readdir");
11
+ const { readDirectory } = require("./utils/recursiveReaddir");
12
12
 
13
13
  const __PUBLISH_EXTRACT_START__ = "__PUBLISH_EXTRACT_START__";
14
14
  const __PUBLISH_EXTRACT_END__ = "__PUBLISH_EXTRACT_END__";
@@ -0,0 +1,96 @@
1
+ const fs = require("fs");
2
+ const p = require("path");
3
+
4
+ function matchesFile(ignorePath) {
5
+ return function (path, stats) {
6
+ return stats.isFile() && ignorePath === path;
7
+ };
8
+ }
9
+
10
+ function toMatcherFunction(ignoreEntry) {
11
+ if (typeof ignoreEntry == "function") {
12
+ return ignoreEntry;
13
+ } else {
14
+ return matchesFile(ignoreEntry);
15
+ }
16
+ }
17
+
18
+ function readdir(path, ignores, callback) {
19
+ if (typeof ignores == "function") {
20
+ callback = ignores;
21
+ ignores = [];
22
+ }
23
+
24
+ if (!callback) {
25
+ return new Promise(function (resolve, reject) {
26
+ readdir(path, ignores || [], function (err, data) {
27
+ if (err) {
28
+ reject(err);
29
+ } else {
30
+ resolve(data);
31
+ }
32
+ });
33
+ });
34
+ }
35
+
36
+ ignores = ignores.map(toMatcherFunction);
37
+
38
+ let list = [];
39
+
40
+ fs.readdir(path, function (err, files) {
41
+ if (err) {
42
+ return callback(err);
43
+ }
44
+
45
+ let pending = files.length;
46
+ if (!pending) {
47
+ // we are done
48
+ return callback(null, list);
49
+ }
50
+
51
+ files.forEach(function (file) {
52
+ const filePath = p.join(path, file);
53
+ fs.stat(filePath, function (_err, stats) {
54
+ if (_err) {
55
+ return callback(_err);
56
+ }
57
+
58
+ if (
59
+ ignores.some(function (matcher) {
60
+ return matcher(filePath, stats);
61
+ })
62
+ ) {
63
+ pending -= 1;
64
+ if (!pending) {
65
+ return callback(null, list);
66
+ }
67
+ return null;
68
+ }
69
+
70
+ if (stats.isDirectory()) {
71
+ readdir(filePath, ignores, function (__err, res) {
72
+ if (__err) {
73
+ return callback(__err);
74
+ }
75
+
76
+ list = list.concat(res);
77
+ pending -= 1;
78
+ if (!pending) {
79
+ return callback(null, list);
80
+ }
81
+ });
82
+ } else {
83
+ list.push(filePath);
84
+ pending -= 1;
85
+ if (!pending) {
86
+ return callback(null, list);
87
+ }
88
+ }
89
+ });
90
+ });
91
+ });
92
+ }
93
+
94
+ module.exports = {
95
+ readDirectory: readdir
96
+ };