@@ -35,6 +35,24 @@ fun computeWorkingDir(nodeProjectDir: DirectoryProperty, execConfiguration: Exec
3535 return workingDir
3636}
3737
38+ /* *
39+ * Helper function to find the best matching executable in the system PATH.
40+ *
41+ * @param executableName The name of the executable to search for.
42+ * @return The best matching executable path as a String.
43+ */
44+ fun findBestExecutableMatch (executableName : String ): String {
45+ val pathVariable = System .getenv(" PATH" ) ? : return executableName
46+ val paths = pathVariable.split(File .pathSeparator)
47+ for (path in paths) {
48+ val executableFile = File (path, executableName)
49+ if (executableFile.exists() && executableFile.canExecute()) {
50+ return executableFile.absolutePath
51+ }
52+ }
53+ return executableName // Return the original executable if no match is found
54+ }
55+
3856/* *
3957 * Basic execution runner that runs a given ExecConfiguration.
4058 *
@@ -43,8 +61,9 @@ fun computeWorkingDir(nodeProjectDir: DirectoryProperty, execConfiguration: Exec
4361 */
4462class ExecRunner {
4563 fun execute (projectHelper : ProjectApiHelper , extension : NodeExtension , execConfiguration : ExecConfiguration ): ExecResult {
64+ val executablePath = findBestExecutableMatch(execConfiguration.executable)
4665 return projectHelper.exec {
47- executable = execConfiguration.executable
66+ executable = executablePath
4867 args = execConfiguration.args
4968 environment = computeEnvironment(execConfiguration)
5069 isIgnoreExitValue = execConfiguration.ignoreExitValue
0 commit comments