Skip to content

Commit e7fb00b

Browse files
committed
Use glob
1 parent 7bd7a65 commit e7fb00b

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

scripts/format-apple.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { exit } = require('process');
2-
const { exec, spawn } = require('child_process');
2+
const { exec } = require('child_process');
33
const path = require('path');
4+
const glob = require('glob');
45

56
function runFormatter(files) {
67
const command = `yarn clang-format -i ${files}`;
@@ -20,24 +21,18 @@ if (argc > 2) {
2021
const files = process.argv.slice(2).join(' ');
2122
runFormatter(files);
2223
} else {
23-
const find = spawn('find', [
24-
path.join(__dirname, '../packages/react-native-gesture-handler/apple'),
25-
'-iname',
26-
'*.h',
27-
'-o',
28-
'-iname',
29-
'*.m',
30-
'-o',
31-
'-iname',
32-
'*.mm',
33-
'-o',
34-
'-iname',
35-
'*.cpp',
36-
]);
24+
const pattern = path.join(
25+
__dirname,
26+
'../packages/react-native-gesture-handler/apple/**/*.{h,m,mm,cpp}'
27+
);
3728

38-
find.stdout.on('data', (data) => {
39-
files = data.toString().trim().replace(/\n/g, ' ');
29+
glob(pattern, (err, filesArray) => {
30+
if (err) {
31+
console.error('Error finding files:', err);
32+
return exit(1);
33+
}
4034

35+
const files = filesArray.join(' ');
4136
runFormatter(files);
4237
});
4338
}

0 commit comments

Comments
 (0)