phenomnomnominal / betterer

betterer makes it easier to make incremental improvements to your codebase
MIT License
582 stars 39 forks source link

VS Code extension: set betterer working directory #943

Open Zinggi opened 2 years ago

Zinggi commented 2 years ago

Hi there :wave: Like https://github.com/phenomnomnominal/betterer/issues/108 I'm trying to run the betterer VS Code extension in a monorepo, but I can't get it to work.

I've set the config path, but it still fails because it can't start betterer:

Validator: Getting Betterer for "/home/.../project_root".
Validator: Betterer isn't installed

It doesn't find betterer, because the project root folder doesn't have a package.json. The package.json and node_modules and hence betterer is not in the project root, they are under ./project_root/sub_folder

Is there a setting to configure the betterer working directory? Or should the config path already do that?

phenomnomnominal commented 2 years ago

Could you give me a bit more information about your project structure and where you've set the config path too?

Zinggi commented 2 years ago

Sure. I'm starting VS Code from this folder:

➤ tree -L 2
.
├── app
│   ├── .betterer.cache
│   ├── .betterer.results
│   ├── .betterer.ts
│   ├── node_modules
│   ├── package.json
│   ├── package-lock.json
│   ├── src
│   └── .....
├── README.md
├── server
│   ├ .....

It has no package.json file. Betterer is installed inside the ./app/ folder.

I tried setting the config path to:

  "betterer.configPath": "./app/.betterer.ts",
  "betterer.cachePath": "./app/.betterer.cache",
  "betterer.resultsPath": "./app/.betterer.results"

but that didn't help, I still get [Error - 4:03:07 PM] Validator: Betterer isn't installed

I suspect it tries to do npx betterer in the VSCode working directory, but in my case it would have to do npx betterer inside the ./app folder.

I don't know how other plugins do it without any configuration, but e.g. prettier uses the right executable without any config. Having a config to specify the better command would also be ok.

andreialecu commented 1 year ago

Had a similar issue and found a workaround: https://github.com/phenomnomnominal/betterer/issues/1034#issuecomment-1441698810