Module: Language::Node::Shebang Private
- Extended by:
- T::Helpers
- Defined in:
- language/node.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Mixin module for Formula adding shebang rewrite features.
Constant Summary collapse
- NODE_SHEBANG_REGEX =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
A regex to match potential shebang permutations.
%r{^#! ?/usr/bin/(?:env )?node( |$)}
- NODE_SHEBANG_MAX_LENGTH =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
The length of the longest shebang matching
SHEBANG_REGEX
. T.let("#! /usr/bin/env node ".length, Integer)
Class Method Summary collapse
Class Method Details
.detected_node_shebang(formula = T.cast(self, Formula)) ⇒ Utils::Shebang::RewriteInfo
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
115 116 117 118 119 120 121 |
# File 'language/node.rb', line 115 def detected_node_shebang(formula = T.cast(self, Formula)) node_deps = formula.deps.select(&:required?).map(&:name).grep(/^node(@.+)?$/) raise ShebangDetectionError.new("Node", "formula does not depend on Node") if node_deps.empty? raise ShebangDetectionError.new("Node", "formula has multiple Node dependencies") if node_deps.length > 1 node_shebang_rewrite_info(Formula[node_deps.first].opt_bin/"node") end |