Skip to content

Commit f697ca7

Browse files
authored
fix(windows): get gradle path with which command (#1793)
1 parent 1d82a3b commit f697ca7

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed

lib/check_reqs.js

+1-41
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
under the License.
1818
*/
1919

20-
const execa = require('execa');
2120
const path = require('node:path');
2221
const fs = require('node:fs');
2322
const { forgivingWhichSync, isWindows, isDarwin } = require('./utils');
@@ -104,46 +103,7 @@ function getUserCompileSdkVersion (projectRoot) {
104103
}
105104

106105
module.exports.get_gradle_wrapper = function () {
107-
let androidStudioPath;
108-
let i = 0;
109-
let foundStudio = false;
110-
let program_dir;
111-
// OK, This hack only works on Windows, not on Mac OS or Linux. We will be deleting this eventually!
112-
if (module.exports.isWindows()) {
113-
// "shell" option enabled for CVE-2024-27980 (Windows) Mitigation
114-
// See https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2 for more details
115-
const result = execa.sync(path.join(__dirname, 'getASPath.bat'), { shell: true });
116-
// console.log('result.stdout =' + result.stdout.toString());
117-
// console.log('result.stderr =' + result.stderr.toString());
118-
119-
if (result.stderr.toString().length > 0) {
120-
const androidPath = path.join(process.env.ProgramFiles, 'Android') + '/';
121-
if (fs.existsSync(androidPath)) {
122-
program_dir = fs.readdirSync(androidPath);
123-
while (i < program_dir.length && !foundStudio) {
124-
if (program_dir[i].startsWith('Android Studio')) {
125-
foundStudio = true;
126-
androidStudioPath = path.join(process.env.ProgramFiles, 'Android', program_dir[i], 'gradle');
127-
} else { ++i; }
128-
}
129-
}
130-
} else {
131-
// console.log('got android studio path from registry');
132-
// remove the (os independent) new line char at the end of stdout
133-
// add gradle to match the above.
134-
androidStudioPath = path.join(result.stdout.toString().split('\r\n')[0], 'gradle');
135-
}
136-
}
137-
138-
if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) {
139-
const dirs = fs.readdirSync(androidStudioPath);
140-
if (dirs[0].split('-')[0] === 'gradle') {
141-
return path.join(androidStudioPath, dirs[0], 'bin', 'gradle');
142-
}
143-
} else {
144-
// OK, let's try to check for Gradle!
145-
return forgivingWhichSync('gradle');
146-
}
106+
return forgivingWhichSync('gradle');
147107
};
148108

149109
// Returns a promise. Called only by build and clean commands.

0 commit comments

Comments
 (0)