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: https://github.com/glebm/critical-rubygem - a Ruby wrapper for the critical npm package.