Formulae that depend on `node` sometimes contain files that use a
shebang like `#!/usr/bin/env node` and this can lead to issues when
the `node` in a user's environment isn't brewed `node`.
For example, some node modules are compiled when the formula is built
but if the user's `node` is a different major version than brew's
`node`, the differing `NODE_MODULE_VERSION` can produce an error when
certain parts of the application are used. The formula may build and
test fine and the issue may only become apparent when more of the
application is exercised.
This adds a `Language::Node::Shebang` module (borrowing from the
existing Perl and Python examples), which allows us to use
`rewrite_shebang detected_node_shebang, ...` in formulae to address
this type of issue.
- Avoid using a temporary variable where not necessary
- Use fewer, better stubs in the tests to avoid warnings and better
test the implemented functionality.
instead of writing a .npmrc file, which simplifies the code.
npm_cache_config is still preserved for backwarts compatiblility and
usage int he kibana@n formulas in core.
This tells npm pack to don't run prepublish scripts at all.
I think this is the best default because:
* most modules don't have a prepublish script at all and aren't affected
by this change
* most prepublish scripts are calling devDeps, which would fail in our
case, because (dev)Deps aren't installed at npm pack time until #2820
gets resolved
* we favor npm registry tarball for formula downloads, which are already
prepublished, so we would in the best case needlessly run prepublish
a second time and in the worst case it would fail (because a clean
step is required before running prepublish a second time in a row)
* This change does the right thing for >99% of all the packages and
would only affect packages with prepublish scripts downloaded from a
non-npm registry tarball (like github tarballs) and with a prepublish
script wich does no't require any devDep (unlike for cross platform)
This fixes some edge cases where verbose output from a prepublish script
could break our npm pack package name detection code by only using the
last line of the output printed by npm itself containing the desired
package name.
By telling node-pre-gyp and prebuild to don't pull prebuild binaries and
instead build them from source. This still may not work for some custom
third party scripts for pulling prebuild binaries.
* add Language::Node helper module
This adds a language module for Node module based formulas.
It contains the 2 public methods `std_npm_install_args(libexec)` and
`local_npm_install_args`:
* `std_npm_install_args` is intended to be used in formulas for
standard node modules and returns `npm install` args for a global
style module installation to libexec.
* `local_npm_install_args` is for formulas, in which the `npm install`
step is only one of multiple parts of the installation process and
returns `npm install` args for a default local installation in place.
Both methods have in common, that they are
* making sure that a working copy of npm and node-gyp from node's
libexec is prepended to the PATH (to not rely of a user managed npm)
* seting the npm cache to HOMEBREW_CACHE/npm, which fixes issues caused
by overriding $HOME resulting in long install times + high disk usage
(see https://github.com/Homebrew/brew/pull/37#issuecomment-208840366)
* audit: update npm install check for Language::Node
* cleanup: remove npm_cache too
* doc: add Node-for-Formula-Authors.md