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.
Fix: #104
As explained in #104, the behavior of
yarn bin
has changed since yarn 2. Also, thenpm 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
andnpm
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 executingnpm bin
. Also, thenpm 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#executablesAnd 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.