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

Remove detection logic for warning on global bazel #801

Merged
merged 1 commit into from
May 29, 2019
Merged
Changes from all commits
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
31 changes: 4 additions & 27 deletions packages/bazel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ const fs = require('fs');
const path = require('path');
const spawnSync = require('child_process').spawnSync;

const warnGlobalInstall = `
*** WARNING
The Bazel binary is being run from a global install.
This means the version may not match the one used in your project.
We recommend installing the @bazel/bazel package locally in your project.
***
`;

/**
* @returns the native `bazel` binary for the current platform
* @throws when the `bazel` executable can not be found
Expand All @@ -24,29 +15,15 @@ function getNativeBinary() {
const platformPackageJson = `@bazel/bazel-${platform}/package.json`;
let nativePackage;
try {
// First, look for the package locally installed under the current working directory
nativePackage = require.resolve(platformPackageJson, {paths: [process.cwd()]});
nativePackage = require.resolve(platformPackageJson);
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
// rethrow other errors
throw e;
}
try {
// Fall back to resolving the package anywhere, but if it succeeds, warn the user that we
// don't recommend relying on a global installation.
nativePackage = require.resolve(platformPackageJson);
console.error(warnGlobalInstall);
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
// rethrow other errors
throw e;
}
// Give up on resolving the correct package anywhere
console.error(
`FATAL: Bazel has not published an executable for your platform. (${platform})\n` +
'Consider installing it following instructions at https://bazel.build instead.\n');
process.exit(1);
}
throw new Error(
`FATAL: Bazel has not published an executable for your platform (${platform})\n` +
'Consider installing it following instructions at https://bazel.build instead.\n');
}

const binary = JSON.parse(fs.readFileSync(nativePackage))['bin']['bazel'];
Expand Down