[healthcheck] Read files from globbed path
ghstack-source-id: a79336c2b1c85ae4d5b941ffbeffb3df10816448 Pull Request resolved: https://github.com/facebook/react-forget/pull/2887
Sathya Gunsasekaran committed
Apr 23, 2024 at 12:28 UTC
9e15ade17729a9a694dc9aa4b2afda0a717e3969
3 files changed
+39
-4
compiler/packages/health-check/package.json
+2
-2
@@ -7,10 +7,10 @@
7
"test": "echo 'no tests'"
8
},
9
"dependencies": {
10
+ "fast-glob": "^3.3.2",
11
"yargs": "^17.7.2"
12
},
12
- "devDependencies": {
13
- },
13
+ "devDependencies": {},
14
"engines": {
15
"node": "^14.17.0 || ^16.0.0 || >= 18.0.0"
16
},
compiler/packages/health-check/src/index.ts
+26
-2
@@ -5,9 +5,10 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
+import { glob } from "fast-glob";
9
import yargs from "yargs/yargs";
10
10
-function main() {
11
+async function main() {
12
const argv = yargs(process.argv.slice(2))
13
.scriptName("healthcheck")
14
.usage("$ npx healthcheck <src>")
@@ -18,7 +19,30 @@ function main() {
19
})
20
.parseSync();
21
21
- console.log(argv.src);
22
+ let src = argv.src;
23
+
24
+ // no file extension specified
25
+ if (!src.includes(".")) {
26
+ src = src + ".{js,ts,jsx,tsx,mjs}";
27
+ }
28
+
29
+ const globOptions = {
30
+ onlyFiles: true,
31
+ ignore: [
32
+ "*/node_modules/**",
33
+ "*/dist/**",
34
+ "*/tests/**",
35
+ "*/__tests__/**",
36
+ "node_modules/**",
37
+ "dist/**",
38
+ "tests/**",
39
+ "__tests__/**",
40
+ ],
41
+ };
42
+
43
+ for (const path of await glob(src, globOptions)) {
44
+ console.log(path);
45
+ }
46
}
47
48
main();
compiler/yarn.lock
+11
@@ -5124,6 +5124,17 @@ fast-glob@^3.2.11, fast-glob@^3.2.12, fast-glob@^3.2.9:
5124
merge2 "^1.3.0"
5125
micromatch "^4.0.4"
5126
5127
+fast-glob@^3.3.2:
5128
+ version "3.3.2"
5129
+ resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129"
5130
+ integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==
5131
+ dependencies:
5132
+ "@nodelib/fs.stat" "^2.0.2"
5133
+ "@nodelib/fs.walk" "^1.2.3"
5134
+ glob-parent "^5.1.2"
5135
+ merge2 "^1.3.0"
5136
+ micromatch "^4.0.4"
5137
+
5138
fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0:
5139
version "2.1.0"
5140
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"