Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle relative buildifier path without warning #387

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/buildifier/buildifier_availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as fs from "fs";
import * as path from "path";
import * as vscode from "vscode";
import * as which from "which";

Expand All @@ -33,9 +35,15 @@ const BUILDTOOLS_RELEASES_URL =
*/
export async function checkBuildifierIsAvailable() {
const buildifierExecutable = getDefaultBuildifierExecutablePath();

// Check if the program exists (in case it's an actual executable and not
// an target name starting with `@`).
if (!buildifierExecutable.startsWith("@")) {
const isTarget = buildifierExecutable.startsWith("@")

// Check if the program exists as a relative path of the workspace
const isRelative = fs.existsSync(path.join(vscode.workspace.workspaceFolders?.[0]?.uri?.fsPath, buildifierExecutable));
vogelsgesang marked this conversation as resolved.
Show resolved Hide resolved
vogelsgesang marked this conversation as resolved.
Show resolved Hide resolved
vogelsgesang marked this conversation as resolved.
Show resolved Hide resolved
vogelsgesang marked this conversation as resolved.
Show resolved Hide resolved

if (!isTarget && !isRelative) {
try {
await which(buildifierExecutable);
} catch (e) {
Expand Down
Loading