Ruby gems with npm packages

I have figured out a robust way to have ruby gems depend on npm packages.
Ruby will install the npm dependencies during gem installation (using an extconf.rb trick), and fail to install if npm installation fails for whatever reason.

Example: GitHub - glebm/critical-rubygem: The `critical` npm package wrapped as a Ruby gem - a Ruby wrapper for the critical npm package.