sighmon / mjml-rails

MJML + ERb/Haml/Slim view template
https://mjml.io
Other
295 stars 64 forks source link

Support for JS Package Manager updates #107

Closed yuta-hayashi closed 1 year ago

yuta-hayashi commented 1 year ago

Fix: #104

As explained in #104, the behavior of yarn bin has changed since yarn 2. Also, the npm bin command has been removed since npm 9. This PR has been modified to support the new versions of yarn and npm as follows.

For yarn, the yarn bin mjml command outputs the full path to the mjml binary, so use that.

However, npm does not have such a command, and npx and npm exec have more overhead than executing the binary directly.

So I used the npm root command to get the full path of the local node_modules and appended the .bin directory. This is the same path as the result of executing npm bin. Also, the npm root command works with npm 6~9. Refs: https://docs.npmjs.com/cli/v9/commands/npm-root https://docs.npmjs.com/cli/v9/configuring-npm/folders?v=true#executables

And I removed the bin_path_from method that was common to yarn and npm because of the difference in execution commands and processing.

It works correctly in my Rails Project using npm9, and I have verified it with yarn 2.

yuta-hayashi commented 1 year ago

@sighmon Hi, could you review this PR?

sighmon commented 1 year ago

@yuta-hayashi Sorry for the delay - I'll have time this weekend to look through it.