doc/dependencies.html
<!DOCTYPE html><html lang="en"><head><title>dependencies</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="dependencies"><meta name="groc-project-path" content="lib/dependencies.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">lib/dependencies.js</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="kd">var</span> <span class="nx">deps</span> <span class="o">=</span> <span class="nx">module</span><span class="p">.</span><span class="nx">exports</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments doc-section"><div class="wrapper"><p>Retrieve the path to binaries installed as part of
npm dependency packages. This is done by getting
the path to any available module, then deconstructing
the path to get the node_modules/.bin directory path.
Currently the binary is assumed to have the same name
as the module. This is fragile - it just happens that
both casperjs and phantomjs meet that condition.</p>
<p>Parameters:</p>
<ul>
<li><strong>module must be a String.</strong><br/>(name of the module)</li>
</ul>
<p><strong>Returns a String</strong><br/>(path to the binary)</p></div></div><div class="code"><div class="wrapper"><span class="nx">deps</span><span class="p">.</span><span class="nx">getbinpath</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">module</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">log</span><span class="p">.</span><span class="nx">debug</span><span class="p">(</span><span class="s1">'function getbinpath: '</span> <span class="o">+</span> <span class="nx">module</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">modpath</span> <span class="o">=</span> <span class="nx">require</span><span class="p">.</span><span class="nx">resolve</span><span class="p">(</span><span class="s1">'shelljs'</span><span class="p">).</span><span class="nx">split</span><span class="p">(</span><span class="s1">'/'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">phantomidx</span> <span class="o">=</span> <span class="nx">modpath</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">'shelljs'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">binpath</span> <span class="o">=</span> <span class="nx">modpath</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">phantomidx</span><span class="p">);</span>
<span class="nx">binpath</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="s1">'.bin'</span><span class="p">);</span>
<span class="nx">binpath</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">module</span><span class="p">);</span>
<span class="nx">binpath</span> <span class="o">=</span> <span class="nx">binpath</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">'/'</span><span class="p">);</span>
<span class="nx">log</span><span class="p">.</span><span class="nx">debug</span><span class="p">(</span><span class="s1">'path for module :'</span> <span class="o">+</span> <span class="nx">module</span> <span class="o">+</span> <span class="s1">': '</span> <span class="o">+</span> <span class="nx">binpath</span><span class="p">);</span>
<span class="k">return</span><span class="p">(</span><span class="nx">binpath</span><span class="p">);</span>
<span class="p">};</span></div></div></div></div></body></html>