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

Tweak bsc path algorithm. #59

Merged
merged 1 commit into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions server/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import * as path from "path";
// version is fixed to 2.0
export let jsonrpcVersion = "2.0";
export let bscPartialPath = path.join(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this to bscExePartialPath then?

"node_modules",
"bs-platform",
process.platform,
"bsc.exe"
"node_modules",
"bs-platform",
process.platform,
"bsc.exe"
);

export let bscNodePartialPath = path.join("node_modules", ".bin", "bsc");

// can't use the native bsb since we might need the watcher -w flag, which is only in the js wrapper
// export let bsbPartialPath = path.join('node_modules', 'bs-platform', process.platform, 'bsb.exe');
export let bsbPartialPath = path.join("node_modules", ".bin", "bsb");
Expand Down
14 changes: 12 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,21 @@ process.on("message", (msg: m.Message) => {
process.send!(fakeSuccessResponse);
process.send!(response);
} else {
let bscExists = false;
let bscPath = path.join(projectRootPath, c.bscPartialPath);
if (!fs.existsSync(bscPath)) {
bscExists = fs.existsSync(bscPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge and tweak this bit. Thanks

if (!bscExists) {
// In certain cases the native bsc binaries might be put in an unknown location
// on the file system. Example: yarn workspaces.
// The only other guarantee we have is that the node bsc should be available in the
// project root + ./node_modules/.bin cf. package.json
bscPath = path.join(projectRootPath, c.bscNodePartialPath);
bscExists = fs.existsSync(bscPath);
}
if (!bscExists) {
let params: p.ShowMessageParams = {
type: p.MessageType.Error,
message: `Cannot find a nearby ${c.bscPartialPath}. It's needed for formatting.`,
message: `Cannot find a nearby ${c.bscNodePartialPath}. It's needed for formatting.`,
};
let response: m.NotificationMessage = {
jsonrpc: c.jsonrpcVersion,
Expand Down