Skip to content

Commit 44911a3

Browse files
IwanBlueHotDog
Iwan
authored andcommitted
Tweak heuristics to find the project root.
The project root means "this is a folder containing node_modules/bs-platform/{platform}/bsc.exe". This path needs to be correct because it drives the formatter. The previous heuristics seemed to fail in the case users where using yarn workspaces. Yarn workspaces seem to have the following layout: ``` /root /node_modules - package.json - yarn.lock /folder1 /node_modules - package.json - bsconfig.json ``` The compiler seems to be located in the `node_modules` under the root and not in the `node_modules` of `folder1`. By searching for `bscPartialPath` instead of the nearest `bsconfig.json`, we can correctly determine the root.
1 parent 0c029ba commit 44911a3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

server/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ process.on("message", (msg: m.Message) => {
415415
if (projectRootPath == null) {
416416
let params: p.ShowMessageParams = {
417417
type: p.MessageType.Error,
418-
message: `Cannot find a nearby ${c.bsconfigPartialPath}. It's needed for determining the project's root.`,
418+
message: `Cannot find a nearby ${c.bscPartialPath}. It's needed for determining the project's root.`,
419419
};
420420
let response: m.NotificationMessage = {
421421
jsonrpc: c.jsonrpcVersion,

server/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export let findProjectRootOfFile = (
2222
source: p.DocumentUri
2323
): null | p.DocumentUri => {
2424
let dir = path.dirname(source);
25-
if (fs.existsSync(path.join(dir, c.bsconfigPartialPath))) {
25+
if (fs.existsSync(path.join(dir, c.bscPartialPath))) {
2626
return dir;
2727
} else {
2828
if (dir === source) {

0 commit comments

Comments
 (0)