Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[docs] update cli

  • Loading branch information...
commit c4834eb5de4cdb954f1d9dfd10c73391b707819f 1 parent a8962ba
Fedor Indutny indutny authored
Showing with 6 additions and 12 deletions.
  1. +6 −12 cli.html
18 cli.html
View
@@ -4,10 +4,6 @@
<h4>@options {Object} Compiler options</h4>
<p>Compiles input stream or file and writes result to output stream or file</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">run</span> <span class="o">=</span> <span class="kd">function</span> <span class="nx">run</span><span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">options</span><span class="p">.</span><span class="nx">input</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">finish</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">input</span><span class="p">).</span><span class="nx">toString</span><span class="p">());</span>
- <span class="p">}</span>
-
<span class="kd">var</span> <span class="nx">input</span> <span class="o">=</span> <span class="p">[];</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">input</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">chunk</span><span class="p">)</span> <span class="p">{</span>
@@ -18,6 +14,8 @@
<span class="nx">finish</span><span class="p">(</span><span class="nx">input</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">));</span>
<span class="p">});</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">input</span><span class="p">.</span><span class="nx">resume</span><span class="p">();</span>
+
<span class="kd">function</span> <span class="nx">finish</span><span class="p">(</span><span class="nx">input</span><span class="p">)</span> <span class="p">{</span>
<span class="k">try</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">out</span> <span class="o">=</span> <span class="nx">ometajs</span><span class="p">.</span><span class="nx">translateCode</span><span class="p">(</span><span class="nx">input</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
@@ -33,15 +31,11 @@
<span class="k">throw</span> <span class="nx">e</span><span class="p">;</span>
<span class="p">}</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">options</span><span class="p">.</span><span class="nx">output</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">fs</span><span class="p">.</span><span class="nx">writeFileSync</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">output</span><span class="p">,</span> <span class="nx">out</span><span class="p">);</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">out</span><span class="p">);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">output</span> <span class="o">!==</span> <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">end</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
- <span class="nx">options</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">out</span><span class="p">);</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">output</span> <span class="o">!==</span> <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">options</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">end</span><span class="p">();</span>
- <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
- <span class="nx">options</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">);</span>
- <span class="p">}</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="p">};</span>
Please sign in to comment.
Something went wrong with that request. Please try again.