Skip to content

Commit 2c69744

Browse files
committed
react-native-codegen: Switch scripts to tinyglobby
1 parent 07db5f8 commit 2c69744

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

packages/react-native-codegen/scripts/build.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525

2626
const babel = require('@babel/core');
2727
const fs = require('fs');
28-
const glob = require('glob');
2928
const micromatch = require('micromatch');
3029
const path = require('path');
3130
const prettier = require('prettier');
31+
const {globSync} = require('tinyglobby');
3232
const {styleText} = require('util');
3333

3434
const prettierConfig = JSON.parse(
@@ -106,8 +106,11 @@ async function buildFile(file, silent) {
106106
}
107107

108108
const srcDir = path.resolve(__dirname, '..', SRC_DIR);
109-
const pattern = path.resolve(srcDir, '**/*');
110-
const files = glob.sync(pattern, {nodir: true});
109+
const files = globSync('**/*', {
110+
cwd: srcDir,
111+
absolute: true,
112+
onlyFiles: true,
113+
});
111114

112115
process.stdout.write(fixedWidth(`${path.basename(PACKAGE_DIR)}\n`));
113116

packages/react-native-codegen/src/cli/combine/combine-js-to-schema.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const {FlowParser} = require('../../parsers/flow/parser');
1515
const {TypeScriptParser} = require('../../parsers/typescript/parser');
1616
const {filterJSFile} = require('./combine-utils');
1717
const fs = require('fs');
18-
const glob = require('glob');
1918
const path = require('path');
19+
const {globSync} = require('tinyglobby');
2020

2121
const flowParser = new FlowParser();
2222
const typescriptParser = new TypeScriptParser();
@@ -66,13 +66,11 @@ function expandDirectoriesIntoFiles(
6666
if (!fs.lstatSync(file).isDirectory()) {
6767
return [file];
6868
}
69-
const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
70-
return glob.sync(`${filePattern}/**/*{,.fb}.{js,ts,tsx}`, {
71-
nodir: true,
72-
// TODO: This will remove the need of slash substitution above for Windows,
73-
// but it requires glob@v9+; with the package currenlty relying on
74-
// [email protected]; and flow-typed repo not having definitions for glob@9+.
75-
// windowsPathsNoEscape: true,
69+
return globSync('**/*{,.fb}.{js,ts,tsx}', {
70+
expandDirectories: false,
71+
onlyFiles: true,
72+
absolute: true,
73+
cwd: file,
7674
});
7775
})
7876
.filter(element => filterJSFile(element, platform, exclude));

0 commit comments

Comments
 (0)