thefrontside / frontmacs

Package-based, web-centric, customizable, awesome-by-default, acceptance-tested Emacs distribution
MIT License
501 stars 22 forks source link

Add node_modules/.bin to buffer's exec-path #123

Closed cowboyd closed 6 years ago

cowboyd commented 6 years ago

In order to run project-specific executables like eslint and/or stylelint, it is typical to use either yarn run or npm run to use the installed version. However, Emacs currently doesn't know to use these executables, and will search for them in the normal path. For example, this means that the eslint style checks won't work unless the eslint executable is installed globally which is rarely the case.

Luckily, this is a solved problem. This PR adds a dependency on the add-node-modules-path package and uses it to append node_modules/.bin to the exec-path for any buffer that is in prog-mode.

Why prog-mode and not js-mode? Because there are often non-JavaScript source files in your project that nevertheless use tools written in JavaScript for them to work. An example of this is stylelint. It's writteni in JavaScript, but we want it to be on the exec-path for CSS files too; not just JavaScript files.

Before

image

After

image

Robdel12 commented 6 years ago

Our CI for frontmacs is pretty unstable :/ (I feel like I see more fails due to bit rot than legit fails)

cowboyd commented 6 years ago

Yeah, I'm feeling this too. Here's the relevant pull request https://github.com/cask/cask/pull/423