Skip to content

Commit 4c64275

Browse files
authored
Added new and upcoming files names to the list of files marking the root of a repo / workspace (#323)
Added new 'MODULE.bazel' file and upcoming 'REPO.bazel' file to the list of files that mark the root of a repository / workspace. Align search order with other implementations.
1 parent 38817b2 commit 4c64275

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/bazel/bazel_utils.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,21 @@ export function getBazelWorkspaceFolder(fsPath: string): string | undefined {
100100
// match the checks below. Having this failsafe guarantees that we don't
101101
// hang in an infinite loop.
102102
const maxIterations = 100;
103+
104+
// These are the names of the files that mark the root of a repository
105+
// or workspace.
106+
const REPO_ROOT_FILE_NAMES = [
107+
"MODULE.bazel",
108+
"REPO.bazel",
109+
"WORKSPACE.bazel",
110+
"WORKSPACE",
111+
];
112+
103113
if (fs.statSync(fsPath).isFile()) {
104114
dirname = path.dirname(dirname);
105115
}
106116
do {
107-
const WORKSPACE_FILES = ["WORKSPACE.bazel", "WORKSPACE"];
108-
for (const workspaceFileName of WORKSPACE_FILES) {
117+
for (const workspaceFileName of REPO_ROOT_FILE_NAMES) {
109118
const workspace = path.join(dirname, workspaceFileName);
110119
try {
111120
fs.accessSync(workspace, fs.constants.F_OK);

0 commit comments

Comments
 (0)