-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-gradle-search.js
33 lines (28 loc) · 1.12 KB
/
build-gradle-search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require('fs');
const path = require('path');
function findModuleBuildGradle(androidDir) {
const files = fs.readdirSync(androidDir);
// Check each item in the directory
for (const file of files) {
const filePath = path.join(androidDir, file);
const stat = fs.statSync(filePath);
// If it's a directory, recursively search inside
if (stat.isDirectory()) {
// Skip the "build" directory and the project-level build.gradle
if (file !== 'build' && file !== 'build.gradle') {
const gradleFilePath = path.join(filePath, 'build.gradle');
if (fs.existsSync(gradleFilePath)) {
return gradleFilePath;
} else {
// Recursive call to search inside the directory
const result = findModuleBuildGradle(filePath);
if (result) {
return result;
}
}
}
}
}
return null; // Return null if no build.gradle file found in any module
}
module.exports = findModuleBuildGradle