Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[added] the mkdir function to Compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
thealjey committed Jan 8, 2016
1 parent 18ba82f commit 4cc3c3c
Show file tree
Hide file tree
Showing 8 changed files with 628 additions and 26 deletions.
170 changes: 169 additions & 1 deletion docs/Compiler.html
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,174 @@ <h5>Returns:</h5>



</dd>



<hr>
<dt>
<h4 class="name" id="mkdir"><span class="type-signature">&lt;protected> </span>mkdir(path, callback)</h4>


</dt>
<dd>


<div class="description">
<p>Recursively creates a directory containing a file specified by <code>path</code>.</p>
</div>








<h5>Parameters:</h5>


<table class="params table table-striped">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>path</code></td>


<td class="type">


<span class="param-type">string</span>




</td>





<td class="description last"><p>a path to a file</p></td>
</tr>



<tr>

<td class="name"><code>callback</code></td>


<td class="type">


<span class="param-type">function</span>




</td>





<td class="description last"><p>a callback function</p></td>
</tr>


</tbody>
</table>




<dl class="details">





























<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Compiler.js.html">Compiler.js</a>,
<a href="Compiler.js.html#sunlight-1-line-104">line 104</a>
</li>
</ul>
</dd>







</dl>















<h5>Example</h5>

<pre class="sunlight-highlight-javascript">compiler.mkdir(&#x27;/path/to/a/file&#x27;, callback);</pre>



</dd>


Expand Down Expand Up @@ -1003,7 +1171,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="Compiler.js.html">Compiler.js</a>,
<a href="Compiler.js.html#sunlight-1-line-107">line 107</a>
<a href="Compiler.js.html#sunlight-1-line-125">line 125</a>
</li>
</ul>
</dd>
Expand Down
26 changes: 22 additions & 4 deletions docs/Compiler.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ <h1 class="page-title">Source: Compiler.js</h1>
* compiler.fsWrite('/path/to/an/output/file', data, callback);
*/
fsWrite(path: string, data: ProgramData, callback: () => void) {
mkdirp(dirname(path), mkdirpErr => {
if (mkdirpErr) {
return console.error(mkdirpErr);
}
this.mkdir(path, () => {
writeFile(path, data.code, scriptErr => {
if (scriptErr) {
return console.error(scriptErr);
Expand All @@ -180,6 +177,27 @@ <h1 class="page-title">Source: Compiler.js</h1>
});
}

/**
* Recursively creates a directory containing a file specified by `path`.
*
* @memberOf Compiler
* @instance
* @protected
* @method mkdir
* @param {string} path - a path to a file
* @param {Function} callback - a callback function
* @example
* compiler.mkdir('/path/to/a/file', callback);
*/
mkdir(path: string, callback: () => void) {
mkdirp(dirname(path), mkdirpErr => {
if (mkdirpErr) {
return console.error(mkdirpErr);
}
callback();
});
}

/**
* Minifies and g-zips the program
*
Expand Down
Loading

0 comments on commit 4cc3c3c

Please sign in to comment.