Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5d4d3ff67 | |||
075ffff713 | |||
641218e841 | |||
0ad455a483 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,7 +1,12 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
.settings/
|
||||||
.idea/
|
.idea/
|
||||||
|
coverage/
|
||||||
|
docs/
|
||||||
|
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
ts/typings/
|
ts/typings/
|
||||||
|
|
||||||
|
test/assets/
|
||||||
|
|
||||||
|
4
.npmignore
Normal file
4
.npmignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
coverage/
|
||||||
|
docs/
|
||||||
|
test/
|
||||||
|
ts/
|
@ -1,6 +1,11 @@
|
|||||||
# smartfile
|
# smartfile
|
||||||
make files easily accessible for processing in javascript.
|
make files easily accessible for processing in javascript.
|
||||||
|
|
||||||
|
## Status
|
||||||
|
[](https://travis-ci.org/pushrocks/smartfile)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/smartfile/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/smartfile)
|
||||||
|
|
||||||
## Supported file types:
|
## Supported file types:
|
||||||
* .yml .yaml
|
* .yml .yaml
|
||||||
* .json
|
* .json
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,212 +0,0 @@
|
|||||||
body, html {
|
|
||||||
margin:0; padding: 0;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
font-family: Helvetica Neue, Helvetica, Arial;
|
|
||||||
font-size: 14px;
|
|
||||||
color:#333;
|
|
||||||
}
|
|
||||||
.small { font-size: 12px;; }
|
|
||||||
*, *:after, *:before {
|
|
||||||
-webkit-box-sizing:border-box;
|
|
||||||
-moz-box-sizing:border-box;
|
|
||||||
box-sizing:border-box;
|
|
||||||
}
|
|
||||||
h1 { font-size: 20px; margin: 0;}
|
|
||||||
h2 { font-size: 14px; }
|
|
||||||
pre {
|
|
||||||
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
-moz-tab-size: 2;
|
|
||||||
-o-tab-size: 2;
|
|
||||||
tab-size: 2;
|
|
||||||
}
|
|
||||||
a { color:#0074D9; text-decoration:none; }
|
|
||||||
a:hover { text-decoration:underline; }
|
|
||||||
.strong { font-weight: bold; }
|
|
||||||
.space-top1 { padding: 10px 0 0 0; }
|
|
||||||
.pad2y { padding: 20px 0; }
|
|
||||||
.pad1y { padding: 10px 0; }
|
|
||||||
.pad2x { padding: 0 20px; }
|
|
||||||
.pad2 { padding: 20px; }
|
|
||||||
.pad1 { padding: 10px; }
|
|
||||||
.space-left2 { padding-left:55px; }
|
|
||||||
.space-right2 { padding-right:20px; }
|
|
||||||
.center { text-align:center; }
|
|
||||||
.clearfix { display:block; }
|
|
||||||
.clearfix:after {
|
|
||||||
content:'';
|
|
||||||
display:block;
|
|
||||||
height:0;
|
|
||||||
clear:both;
|
|
||||||
visibility:hidden;
|
|
||||||
}
|
|
||||||
.fl { float: left; }
|
|
||||||
@media only screen and (max-width:640px) {
|
|
||||||
.col3 { width:100%; max-width:100%; }
|
|
||||||
.hide-mobile { display:none!important; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.quiet {
|
|
||||||
color: #7f7f7f;
|
|
||||||
color: rgba(0,0,0,0.5);
|
|
||||||
}
|
|
||||||
.quiet a { opacity: 0.7; }
|
|
||||||
|
|
||||||
.fraction {
|
|
||||||
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
||||||
font-size: 10px;
|
|
||||||
color: #555;
|
|
||||||
background: #E8E8E8;
|
|
||||||
padding: 4px 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.path a:link, div.path a:visited { color: #333; }
|
|
||||||
table.coverage {
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin: 10px 0 0 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.coverage td {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
table.coverage td.line-count {
|
|
||||||
text-align: right;
|
|
||||||
padding: 0 5px 0 20px;
|
|
||||||
}
|
|
||||||
table.coverage td.line-coverage {
|
|
||||||
text-align: right;
|
|
||||||
padding-right: 10px;
|
|
||||||
min-width:20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.coverage td span.cline-any {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 0 5px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.missing-if-branch {
|
|
||||||
display: inline-block;
|
|
||||||
margin-right: 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
position: relative;
|
|
||||||
padding: 0 4px;
|
|
||||||
background: #333;
|
|
||||||
color: yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
.skip-if-branch {
|
|
||||||
display: none;
|
|
||||||
margin-right: 10px;
|
|
||||||
position: relative;
|
|
||||||
padding: 0 4px;
|
|
||||||
background: #ccc;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
||||||
color: inherit !important;
|
|
||||||
}
|
|
||||||
.coverage-summary {
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
||||||
.keyline-all { border: 1px solid #ddd; }
|
|
||||||
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
||||||
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
||||||
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
||||||
.coverage-summary td:last-child { border-right: none; }
|
|
||||||
.coverage-summary th {
|
|
||||||
text-align: left;
|
|
||||||
font-weight: normal;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.coverage-summary th.file { border-right: none !important; }
|
|
||||||
.coverage-summary th.pct { }
|
|
||||||
.coverage-summary th.pic,
|
|
||||||
.coverage-summary th.abs,
|
|
||||||
.coverage-summary td.pct,
|
|
||||||
.coverage-summary td.abs { text-align: right; }
|
|
||||||
.coverage-summary td.file { white-space: nowrap; }
|
|
||||||
.coverage-summary td.pic { min-width: 120px !important; }
|
|
||||||
.coverage-summary tfoot td { }
|
|
||||||
|
|
||||||
.coverage-summary .sorter {
|
|
||||||
height: 10px;
|
|
||||||
width: 7px;
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 0.5em;
|
|
||||||
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
||||||
}
|
|
||||||
.coverage-summary .sorted .sorter {
|
|
||||||
background-position: 0 -20px;
|
|
||||||
}
|
|
||||||
.coverage-summary .sorted-desc .sorter {
|
|
||||||
background-position: 0 -10px;
|
|
||||||
}
|
|
||||||
.status-line { height: 10px; }
|
|
||||||
/* dark red */
|
|
||||||
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
||||||
.low .chart { border:1px solid #C21F39 }
|
|
||||||
/* medium red */
|
|
||||||
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
||||||
/* light red */
|
|
||||||
.low, .cline-no { background:#FCE1E5 }
|
|
||||||
/* light green */
|
|
||||||
.high, .cline-yes { background:rgb(230,245,208) }
|
|
||||||
/* medium green */
|
|
||||||
.cstat-yes { background:rgb(161,215,106) }
|
|
||||||
/* dark green */
|
|
||||||
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
||||||
.high .chart { border:1px solid rgb(77,146,33) }
|
|
||||||
|
|
||||||
|
|
||||||
.medium .chart { border:1px solid #666; }
|
|
||||||
.medium .cover-fill { background: #666; }
|
|
||||||
|
|
||||||
.cbranch-no { background: yellow !important; color: #111; }
|
|
||||||
|
|
||||||
.cstat-skip { background: #ddd; color: #111; }
|
|
||||||
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
||||||
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
||||||
|
|
||||||
span.cline-neutral { background: #eaeaea; }
|
|
||||||
.medium { background: #eaeaea; }
|
|
||||||
|
|
||||||
.cover-fill, .cover-empty {
|
|
||||||
display:inline-block;
|
|
||||||
height: 12px;
|
|
||||||
}
|
|
||||||
.chart {
|
|
||||||
line-height: 0;
|
|
||||||
}
|
|
||||||
.cover-empty {
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
.cover-full {
|
|
||||||
border-right: none !important;
|
|
||||||
}
|
|
||||||
pre.prettyprint {
|
|
||||||
border: none !important;
|
|
||||||
padding: 0 !important;
|
|
||||||
margin: 0 !important;
|
|
||||||
}
|
|
||||||
.com { color: #999 !important; }
|
|
||||||
.ignore-none { color: #999; font-weight: normal; }
|
|
||||||
|
|
||||||
.wrapper {
|
|
||||||
min-height: 100%;
|
|
||||||
height: auto !important;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0 auto -48px;
|
|
||||||
}
|
|
||||||
.footer, .push {
|
|
||||||
height: 48px;
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Code coverage report for All files</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<link rel="stylesheet" href="prettify.css" />
|
|
||||||
<link rel="stylesheet" href="base.css" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<style type='text/css'>
|
|
||||||
.coverage-summary .sorter {
|
|
||||||
background-image: url(sort-arrow-sprite.png);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class='wrapper'>
|
|
||||||
<div class='pad1'>
|
|
||||||
<h1>
|
|
||||||
/
|
|
||||||
</h1>
|
|
||||||
<div class='clearfix'>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">92.31% </span>
|
|
||||||
<span class="quiet">Statements</span>
|
|
||||||
<span class='fraction'>60/65</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">80.95% </span>
|
|
||||||
<span class="quiet">Branches</span>
|
|
||||||
<span class='fraction'>17/21</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">94.12% </span>
|
|
||||||
<span class="quiet">Functions</span>
|
|
||||||
<span class='fraction'>16/17</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">92.06% </span>
|
|
||||||
<span class="quiet">Lines</span>
|
|
||||||
<span class='fraction'>58/63</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='status-line high'></div>
|
|
||||||
<div class="pad1">
|
|
||||||
<table class="coverage-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
||||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
||||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
||||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
||||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
||||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
||||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody><tr>
|
|
||||||
<td class="file high" data-value="smartfile/"><a href="smartfile/index.html">smartfile/</a></td>
|
|
||||||
<td data-value="92.31" class="pic high"><div class="chart"><div class="cover-fill" style="width: 92%;"></div><div class="cover-empty" style="width:8%;"></div></div></td>
|
|
||||||
<td data-value="92.31" class="pct high">92.31%</td>
|
|
||||||
<td data-value="65" class="abs high">60/65</td>
|
|
||||||
<td data-value="80.95" class="pct high">80.95%</td>
|
|
||||||
<td data-value="21" class="abs high">17/21</td>
|
|
||||||
<td data-value="94.12" class="pct high">94.12%</td>
|
|
||||||
<td data-value="17" class="abs high">16/17</td>
|
|
||||||
<td data-value="92.06" class="pct high">92.06%</td>
|
|
||||||
<td data-value="63" class="abs high">58/63</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div><div class='push'></div><!-- for sticky footer -->
|
|
||||||
</div><!-- /wrapper -->
|
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
|
||||||
Code coverage
|
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 20:50:58 GMT+0100 (CET)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="prettify.js"></script>
|
|
||||||
<script>
|
|
||||||
window.onload = function () {
|
|
||||||
if (typeof prettyPrint === 'function') {
|
|
||||||
prettyPrint();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script src="sorter.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1 +0,0 @@
|
|||||||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
|
File diff suppressed because one or more lines are too long
@ -1,93 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Code coverage report for smartfile/</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<link rel="stylesheet" href="../prettify.css" />
|
|
||||||
<link rel="stylesheet" href="../base.css" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<style type='text/css'>
|
|
||||||
.coverage-summary .sorter {
|
|
||||||
background-image: url(../sort-arrow-sprite.png);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class='wrapper'>
|
|
||||||
<div class='pad1'>
|
|
||||||
<h1>
|
|
||||||
<a href="../index.html">all files</a> smartfile/
|
|
||||||
</h1>
|
|
||||||
<div class='clearfix'>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">92.31% </span>
|
|
||||||
<span class="quiet">Statements</span>
|
|
||||||
<span class='fraction'>60/65</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">80.95% </span>
|
|
||||||
<span class="quiet">Branches</span>
|
|
||||||
<span class='fraction'>17/21</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">94.12% </span>
|
|
||||||
<span class="quiet">Functions</span>
|
|
||||||
<span class='fraction'>16/17</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">92.06% </span>
|
|
||||||
<span class="quiet">Lines</span>
|
|
||||||
<span class='fraction'>58/63</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='status-line high'></div>
|
|
||||||
<div class="pad1">
|
|
||||||
<table class="coverage-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
||||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
||||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
||||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
||||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
||||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
||||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody><tr>
|
|
||||||
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</a></td>
|
|
||||||
<td data-value="92.31" class="pic high"><div class="chart"><div class="cover-fill" style="width: 92%;"></div><div class="cover-empty" style="width:8%;"></div></div></td>
|
|
||||||
<td data-value="92.31" class="pct high">92.31%</td>
|
|
||||||
<td data-value="65" class="abs high">60/65</td>
|
|
||||||
<td data-value="80.95" class="pct high">80.95%</td>
|
|
||||||
<td data-value="21" class="abs high">17/21</td>
|
|
||||||
<td data-value="94.12" class="pct high">94.12%</td>
|
|
||||||
<td data-value="17" class="abs high">16/17</td>
|
|
||||||
<td data-value="92.06" class="pct high">92.06%</td>
|
|
||||||
<td data-value="63" class="abs high">58/63</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div><div class='push'></div><!-- for sticky footer -->
|
|
||||||
</div><!-- /wrapper -->
|
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
|
||||||
Code coverage
|
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 20:50:58 GMT+0100 (CET)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="../prettify.js"></script>
|
|
||||||
<script>
|
|
||||||
window.onload = function () {
|
|
||||||
if (typeof prettyPrint === 'function') {
|
|
||||||
prettyPrint();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script src="../sorter.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,434 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Code coverage report for smartfile/index.js</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<link rel="stylesheet" href="../prettify.css" />
|
|
||||||
<link rel="stylesheet" href="../base.css" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<style type='text/css'>
|
|
||||||
.coverage-summary .sorter {
|
|
||||||
background-image: url(../sort-arrow-sprite.png);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class='wrapper'>
|
|
||||||
<div class='pad1'>
|
|
||||||
<h1>
|
|
||||||
<a href="../index.html">all files</a> / <a href="index.html">smartfile/</a> index.js
|
|
||||||
</h1>
|
|
||||||
<div class='clearfix'>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">92.31% </span>
|
|
||||||
<span class="quiet">Statements</span>
|
|
||||||
<span class='fraction'>60/65</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">80.95% </span>
|
|
||||||
<span class="quiet">Branches</span>
|
|
||||||
<span class='fraction'>17/21</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">94.12% </span>
|
|
||||||
<span class="quiet">Functions</span>
|
|
||||||
<span class='fraction'>16/17</span>
|
|
||||||
</div>
|
|
||||||
<div class='fl pad1y space-right2'>
|
|
||||||
<span class="strong">92.06% </span>
|
|
||||||
<span class="quiet">Lines</span>
|
|
||||||
<span class='fraction'>58/63</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='status-line high'></div>
|
|
||||||
<pre><table class="coverage">
|
|
||||||
<tr><td class="line-count quiet">1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
6
|
|
||||||
7
|
|
||||||
8
|
|
||||||
9
|
|
||||||
10
|
|
||||||
11
|
|
||||||
12
|
|
||||||
13
|
|
||||||
14
|
|
||||||
15
|
|
||||||
16
|
|
||||||
17
|
|
||||||
18
|
|
||||||
19
|
|
||||||
20
|
|
||||||
21
|
|
||||||
22
|
|
||||||
23
|
|
||||||
24
|
|
||||||
25
|
|
||||||
26
|
|
||||||
27
|
|
||||||
28
|
|
||||||
29
|
|
||||||
30
|
|
||||||
31
|
|
||||||
32
|
|
||||||
33
|
|
||||||
34
|
|
||||||
35
|
|
||||||
36
|
|
||||||
37
|
|
||||||
38
|
|
||||||
39
|
|
||||||
40
|
|
||||||
41
|
|
||||||
42
|
|
||||||
43
|
|
||||||
44
|
|
||||||
45
|
|
||||||
46
|
|
||||||
47
|
|
||||||
48
|
|
||||||
49
|
|
||||||
50
|
|
||||||
51
|
|
||||||
52
|
|
||||||
53
|
|
||||||
54
|
|
||||||
55
|
|
||||||
56
|
|
||||||
57
|
|
||||||
58
|
|
||||||
59
|
|
||||||
60
|
|
||||||
61
|
|
||||||
62
|
|
||||||
63
|
|
||||||
64
|
|
||||||
65
|
|
||||||
66
|
|
||||||
67
|
|
||||||
68
|
|
||||||
69
|
|
||||||
70
|
|
||||||
71
|
|
||||||
72
|
|
||||||
73
|
|
||||||
74
|
|
||||||
75
|
|
||||||
76
|
|
||||||
77
|
|
||||||
78
|
|
||||||
79
|
|
||||||
80
|
|
||||||
81
|
|
||||||
82
|
|
||||||
83
|
|
||||||
84
|
|
||||||
85
|
|
||||||
86
|
|
||||||
87
|
|
||||||
88
|
|
||||||
89
|
|
||||||
90
|
|
||||||
91
|
|
||||||
92
|
|
||||||
93
|
|
||||||
94
|
|
||||||
95
|
|
||||||
96
|
|
||||||
97
|
|
||||||
98
|
|
||||||
99
|
|
||||||
100
|
|
||||||
101
|
|
||||||
102
|
|
||||||
103
|
|
||||||
104
|
|
||||||
105
|
|
||||||
106
|
|
||||||
107
|
|
||||||
108
|
|
||||||
109
|
|
||||||
110
|
|
||||||
111
|
|
||||||
112
|
|
||||||
113
|
|
||||||
114
|
|
||||||
115
|
|
||||||
116
|
|
||||||
117
|
|
||||||
118
|
|
||||||
119
|
|
||||||
120
|
|
||||||
121
|
|
||||||
122
|
|
||||||
123
|
|
||||||
124</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">3×</span>
|
|
||||||
<span class="cline-any cline-yes">3×</span>
|
|
||||||
<span class="cline-any cline-yes">3×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">3×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-no"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-yes">2×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-no"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-no"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-no"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-no"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-yes">1×</span>
|
|
||||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfilePlugins;
|
|
||||||
(function (SmartfilePlugins) {
|
|
||||||
SmartfilePlugins.init = function () {
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
fs: require("fs-extra"),
|
|
||||||
path: require("path"),
|
|
||||||
q: require("q"),
|
|
||||||
vinyl: require("vinyl"),
|
|
||||||
vinylFile: require("vinyl-file"),
|
|
||||||
yaml: require("js-yaml"),
|
|
||||||
requireReload: require("require-reload")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
};
|
|
||||||
})(SmartfilePlugins || (SmartfilePlugins = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileCheck;
|
|
||||||
(function (SmartfileCheck) {
|
|
||||||
var checks = {
|
|
||||||
fileExistsSync: function (filePath) {
|
|
||||||
var fileExistsBool = false;
|
|
||||||
try {
|
|
||||||
plugins.fs.readFileSync(filePath);
|
|
||||||
fileExistsBool = true;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
fileExistsBool = false;
|
|
||||||
}
|
|
||||||
return fileExistsBool;
|
|
||||||
},
|
|
||||||
fileExists: function (filePath) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
|
||||||
err ? done.reject() : done.resolve();
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
SmartfileCheck.init = function (objectArg) {
|
|
||||||
objectArg.checks = checks;
|
|
||||||
};
|
|
||||||
})(SmartfileCheck || (SmartfileCheck = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileSimple;
|
|
||||||
(function (SmartfileSimple) {
|
|
||||||
/**
|
|
||||||
* reads a file content to a String
|
|
||||||
* @param filePath
|
|
||||||
* @returns {string|Buffer|any}
|
|
||||||
*/
|
|
||||||
var readFileToString = function (filePath) {
|
|
||||||
var fileString;
|
|
||||||
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
|
||||||
return fileString;
|
|
||||||
};
|
|
||||||
var readFileToObject = function (filePath, fileTypeArg) {
|
|
||||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (fileTypeArg === void 0) { fileTypeArg = "undefined"; }
|
|
||||||
var fileType;
|
|
||||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (fileTypeArg == "undefined") {
|
|
||||||
fileType = plugins.path.extname(filePath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
<span class="cstat-no" title="statement not covered" > fileType = fileTypeArg;</span>
|
|
||||||
}
|
|
||||||
fileType = fileType.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
|
|
||||||
switch (fileType) {
|
|
||||||
<span class="branch-0 cbranch-no" title="branch not covered" > case "yml":</span>
|
|
||||||
case "yaml":
|
|
||||||
try {
|
|
||||||
return plugins.yaml.safeLoad(plugins.fs.readFileSync(filePath, 'utf8'));
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
<span class="cstat-no" title="statement not covered" > plugins.beautylog.error("check that " + filePath.blue + " points to a valid file");</span>
|
|
||||||
}
|
|
||||||
<span class="cstat-no" title="statement not covered" > break;</span>
|
|
||||||
case "json":
|
|
||||||
return plugins.fs.readJsonSync(filePath, {});
|
|
||||||
<span class="cstat-no" title="statement not covered" > break;</span>
|
|
||||||
}
|
|
||||||
};
|
|
||||||
SmartfileSimple.init = function (objectArg) {
|
|
||||||
objectArg.readFileToString = readFileToString;
|
|
||||||
objectArg.readFileToObject = readFileToObject;
|
|
||||||
};
|
|
||||||
})(SmartfileSimple || (SmartfileSimple = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileVinyl;
|
|
||||||
(function (SmartfileVinyl) {
|
|
||||||
var readFileToVinyl = function (filePathArg, options) {
|
|
||||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (options === void 0) { options = {}; }
|
|
||||||
return plugins.vinylFile.readSync(filePathArg, options);
|
|
||||||
};
|
|
||||||
SmartfileVinyl.init = function (objectArg) {
|
|
||||||
objectArg.readFileToVinyl = readFileToVinyl;
|
|
||||||
};
|
|
||||||
})(SmartfileVinyl || (SmartfileVinyl = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileRequire;
|
|
||||||
(function (SmartfileRequire) {
|
|
||||||
var requireReload = <span class="fstat-no" title="function not covered" >function (path) {</span>
|
|
||||||
<span class="cstat-no" title="statement not covered" > return plugins.requireReload(path);</span>
|
|
||||||
};
|
|
||||||
SmartfileRequire.init = function (objectArg) {
|
|
||||||
objectArg.requireReload = requireReload;
|
|
||||||
};
|
|
||||||
})(SmartfileRequire || (SmartfileRequire = {}));
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
/// <reference path="./smartfile.plugins.ts" />
|
|
||||||
/// <reference path="./smartfile.check.ts" />
|
|
||||||
/// <reference path="./smartfile.simple.ts" />
|
|
||||||
/// <reference path="./smartfile.vinyl.ts" />
|
|
||||||
/// <reference path="./smartfile.require.ts" />
|
|
||||||
var plugins = SmartfilePlugins.init();
|
|
||||||
var smartfile = {};
|
|
||||||
SmartfileCheck.init(smartfile);
|
|
||||||
SmartfileSimple.init(smartfile);
|
|
||||||
SmartfileVinyl.init(smartfile);
|
|
||||||
SmartfileRequire.init(smartfile);
|
|
||||||
module.exports = smartfile;
|
|
||||||
</pre></td></tr>
|
|
||||||
</table></pre>
|
|
||||||
<div class='push'></div><!-- for sticky footer -->
|
|
||||||
</div><!-- /wrapper -->
|
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
|
||||||
Code coverage
|
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Feb 09 2016 20:50:58 GMT+0100 (CET)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="../prettify.js"></script>
|
|
||||||
<script>
|
|
||||||
window.onload = function () {
|
|
||||||
if (typeof prettyPrint === 'function') {
|
|
||||||
prettyPrint();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script src="../sorter.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Binary file not shown.
Before Width: | Height: | Size: 209 B |
@ -1,158 +0,0 @@
|
|||||||
var addSorting = (function () {
|
|
||||||
"use strict";
|
|
||||||
var cols,
|
|
||||||
currentSort = {
|
|
||||||
index: 0,
|
|
||||||
desc: false
|
|
||||||
};
|
|
||||||
|
|
||||||
// returns the summary table element
|
|
||||||
function getTable() { return document.querySelector('.coverage-summary'); }
|
|
||||||
// returns the thead element of the summary table
|
|
||||||
function getTableHeader() { return getTable().querySelector('thead tr'); }
|
|
||||||
// returns the tbody element of the summary table
|
|
||||||
function getTableBody() { return getTable().querySelector('tbody'); }
|
|
||||||
// returns the th element for nth column
|
|
||||||
function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; }
|
|
||||||
|
|
||||||
// loads all columns
|
|
||||||
function loadColumns() {
|
|
||||||
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
||||||
colNode,
|
|
||||||
cols = [],
|
|
||||||
col,
|
|
||||||
i;
|
|
||||||
|
|
||||||
for (i = 0; i < colNodes.length; i += 1) {
|
|
||||||
colNode = colNodes[i];
|
|
||||||
col = {
|
|
||||||
key: colNode.getAttribute('data-col'),
|
|
||||||
sortable: !colNode.getAttribute('data-nosort'),
|
|
||||||
type: colNode.getAttribute('data-type') || 'string'
|
|
||||||
};
|
|
||||||
cols.push(col);
|
|
||||||
if (col.sortable) {
|
|
||||||
col.defaultDescSort = col.type === 'number';
|
|
||||||
colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cols;
|
|
||||||
}
|
|
||||||
// attaches a data attribute to every tr element with an object
|
|
||||||
// of data values keyed by column name
|
|
||||||
function loadRowData(tableRow) {
|
|
||||||
var tableCols = tableRow.querySelectorAll('td'),
|
|
||||||
colNode,
|
|
||||||
col,
|
|
||||||
data = {},
|
|
||||||
i,
|
|
||||||
val;
|
|
||||||
for (i = 0; i < tableCols.length; i += 1) {
|
|
||||||
colNode = tableCols[i];
|
|
||||||
col = cols[i];
|
|
||||||
val = colNode.getAttribute('data-value');
|
|
||||||
if (col.type === 'number') {
|
|
||||||
val = Number(val);
|
|
||||||
}
|
|
||||||
data[col.key] = val;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
// loads all row data
|
|
||||||
function loadData() {
|
|
||||||
var rows = getTableBody().querySelectorAll('tr'),
|
|
||||||
i;
|
|
||||||
|
|
||||||
for (i = 0; i < rows.length; i += 1) {
|
|
||||||
rows[i].data = loadRowData(rows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// sorts the table using the data for the ith column
|
|
||||||
function sortByIndex(index, desc) {
|
|
||||||
var key = cols[index].key,
|
|
||||||
sorter = function (a, b) {
|
|
||||||
a = a.data[key];
|
|
||||||
b = b.data[key];
|
|
||||||
return a < b ? -1 : a > b ? 1 : 0;
|
|
||||||
},
|
|
||||||
finalSorter = sorter,
|
|
||||||
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
||||||
rowNodes = tableBody.querySelectorAll('tr'),
|
|
||||||
rows = [],
|
|
||||||
i;
|
|
||||||
|
|
||||||
if (desc) {
|
|
||||||
finalSorter = function (a, b) {
|
|
||||||
return -1 * sorter(a, b);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < rowNodes.length; i += 1) {
|
|
||||||
rows.push(rowNodes[i]);
|
|
||||||
tableBody.removeChild(rowNodes[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.sort(finalSorter);
|
|
||||||
|
|
||||||
for (i = 0; i < rows.length; i += 1) {
|
|
||||||
tableBody.appendChild(rows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// removes sort indicators for current column being sorted
|
|
||||||
function removeSortIndicators() {
|
|
||||||
var col = getNthColumn(currentSort.index),
|
|
||||||
cls = col.className;
|
|
||||||
|
|
||||||
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
||||||
col.className = cls;
|
|
||||||
}
|
|
||||||
// adds sort indicators for current column being sorted
|
|
||||||
function addSortIndicators() {
|
|
||||||
getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted';
|
|
||||||
}
|
|
||||||
// adds event listeners for all sorter widgets
|
|
||||||
function enableUI() {
|
|
||||||
var i,
|
|
||||||
el,
|
|
||||||
ithSorter = function ithSorter(i) {
|
|
||||||
var col = cols[i];
|
|
||||||
|
|
||||||
return function () {
|
|
||||||
var desc = col.defaultDescSort;
|
|
||||||
|
|
||||||
if (currentSort.index === i) {
|
|
||||||
desc = !currentSort.desc;
|
|
||||||
}
|
|
||||||
sortByIndex(i, desc);
|
|
||||||
removeSortIndicators();
|
|
||||||
currentSort.index = i;
|
|
||||||
currentSort.desc = desc;
|
|
||||||
addSortIndicators();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
for (i =0 ; i < cols.length; i += 1) {
|
|
||||||
if (cols[i].sortable) {
|
|
||||||
// add the click event handler on the th so users
|
|
||||||
// dont have to click on those tiny arrows
|
|
||||||
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
||||||
if (el.addEventListener) {
|
|
||||||
el.addEventListener('click', ithSorter(i));
|
|
||||||
} else {
|
|
||||||
el.attachEvent('onclick', ithSorter(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// adds sorting functionality to the UI
|
|
||||||
return function () {
|
|
||||||
if (!getTable()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cols = loadColumns();
|
|
||||||
loadData(cols);
|
|
||||||
addSortIndicators();
|
|
||||||
enableUI();
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
window.addEventListener('load', addSorting);
|
|
@ -1,127 +0,0 @@
|
|||||||
TN:
|
|
||||||
SF:/Users/philkunz/github/pushrocks/smartfile/index.js
|
|
||||||
FN:5,(anonymous_1)
|
|
||||||
FN:6,(anonymous_2)
|
|
||||||
FN:22,(anonymous_3)
|
|
||||||
FN:24,(anonymous_4)
|
|
||||||
FN:35,(anonymous_5)
|
|
||||||
FN:37,(anonymous_6)
|
|
||||||
FN:43,(anonymous_7)
|
|
||||||
FN:49,(anonymous_8)
|
|
||||||
FN:55,(anonymous_9)
|
|
||||||
FN:60,(anonymous_10)
|
|
||||||
FN:85,(anonymous_11)
|
|
||||||
FN:92,(anonymous_12)
|
|
||||||
FN:93,(anonymous_13)
|
|
||||||
FN:97,(anonymous_14)
|
|
||||||
FN:103,(anonymous_15)
|
|
||||||
FN:104,(anonymous_16)
|
|
||||||
FN:107,(anonymous_17)
|
|
||||||
FNF:17
|
|
||||||
FNH:16
|
|
||||||
FNDA:1,(anonymous_1)
|
|
||||||
FNDA:1,(anonymous_2)
|
|
||||||
FNDA:1,(anonymous_3)
|
|
||||||
FNDA:2,(anonymous_4)
|
|
||||||
FNDA:3,(anonymous_5)
|
|
||||||
FNDA:3,(anonymous_6)
|
|
||||||
FNDA:1,(anonymous_7)
|
|
||||||
FNDA:1,(anonymous_8)
|
|
||||||
FNDA:1,(anonymous_9)
|
|
||||||
FNDA:2,(anonymous_10)
|
|
||||||
FNDA:1,(anonymous_11)
|
|
||||||
FNDA:1,(anonymous_12)
|
|
||||||
FNDA:1,(anonymous_13)
|
|
||||||
FNDA:1,(anonymous_14)
|
|
||||||
FNDA:1,(anonymous_15)
|
|
||||||
FNDA:0,(anonymous_16)
|
|
||||||
FNDA:1,(anonymous_17)
|
|
||||||
DA:4,1
|
|
||||||
DA:5,1
|
|
||||||
DA:6,1
|
|
||||||
DA:7,1
|
|
||||||
DA:17,1
|
|
||||||
DA:21,1
|
|
||||||
DA:22,1
|
|
||||||
DA:23,1
|
|
||||||
DA:25,2
|
|
||||||
DA:26,2
|
|
||||||
DA:27,2
|
|
||||||
DA:28,1
|
|
||||||
DA:31,1
|
|
||||||
DA:33,2
|
|
||||||
DA:36,3
|
|
||||||
DA:37,3
|
|
||||||
DA:38,3
|
|
||||||
DA:40,3
|
|
||||||
DA:43,1
|
|
||||||
DA:44,1
|
|
||||||
DA:48,1
|
|
||||||
DA:49,1
|
|
||||||
DA:55,1
|
|
||||||
DA:56,1
|
|
||||||
DA:57,1
|
|
||||||
DA:58,1
|
|
||||||
DA:60,1
|
|
||||||
DA:61,2
|
|
||||||
DA:62,2
|
|
||||||
DA:63,2
|
|
||||||
DA:64,2
|
|
||||||
DA:67,0
|
|
||||||
DA:69,2
|
|
||||||
DA:70,2
|
|
||||||
DA:73,1
|
|
||||||
DA:74,1
|
|
||||||
DA:77,0
|
|
||||||
DA:79,0
|
|
||||||
DA:81,1
|
|
||||||
DA:82,0
|
|
||||||
DA:85,1
|
|
||||||
DA:86,1
|
|
||||||
DA:87,1
|
|
||||||
DA:91,1
|
|
||||||
DA:92,1
|
|
||||||
DA:93,1
|
|
||||||
DA:94,1
|
|
||||||
DA:95,1
|
|
||||||
DA:97,1
|
|
||||||
DA:98,1
|
|
||||||
DA:102,1
|
|
||||||
DA:103,1
|
|
||||||
DA:104,1
|
|
||||||
DA:105,0
|
|
||||||
DA:107,1
|
|
||||||
DA:108,1
|
|
||||||
DA:117,1
|
|
||||||
DA:118,1
|
|
||||||
DA:119,1
|
|
||||||
DA:120,1
|
|
||||||
DA:121,1
|
|
||||||
DA:122,1
|
|
||||||
DA:123,1
|
|
||||||
LF:63
|
|
||||||
LH:58
|
|
||||||
BRDA:19,1,0,1
|
|
||||||
BRDA:19,1,1,1
|
|
||||||
BRDA:38,2,0,1
|
|
||||||
BRDA:38,2,1,2
|
|
||||||
BRDA:46,3,0,1
|
|
||||||
BRDA:46,3,1,1
|
|
||||||
BRDA:61,4,0,2
|
|
||||||
BRDA:61,4,1,0
|
|
||||||
BRDA:63,5,0,2
|
|
||||||
BRDA:63,5,1,0
|
|
||||||
BRDA:70,6,0,0
|
|
||||||
BRDA:70,6,1,1
|
|
||||||
BRDA:70,6,2,1
|
|
||||||
BRDA:89,7,0,1
|
|
||||||
BRDA:89,7,1,1
|
|
||||||
BRDA:94,8,0,1
|
|
||||||
BRDA:94,8,1,0
|
|
||||||
BRDA:100,9,0,1
|
|
||||||
BRDA:100,9,1,1
|
|
||||||
BRDA:110,10,0,1
|
|
||||||
BRDA:110,10,1,1
|
|
||||||
BRF:21
|
|
||||||
BRH:17
|
|
||||||
end_of_record
|
|
15
dist/index.js
vendored
Normal file
15
dist/index.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
"use strict";
|
||||||
|
var SmartfileChecks = require("./smartfile.checks");
|
||||||
|
var SmartfileSimple = require("./smartfile.simple");
|
||||||
|
var smartfile = {
|
||||||
|
copy: SmartfileSimple.copy,
|
||||||
|
checks: SmartfileChecks,
|
||||||
|
readFileToString: SmartfileSimple.readFileToString,
|
||||||
|
readFileToObject: SmartfileSimple.readFileToObject,
|
||||||
|
readFileToVinyl: SmartfileSimple.readFileToVinyl,
|
||||||
|
requireReload: SmartfileSimple.requireReload
|
||||||
|
};
|
||||||
|
module.exports = smartfile;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFHNUMsSUFBTyxlQUFlLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUN2RCxJQUFPLGVBQWUsV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBR3ZELElBQUksU0FBUyxHQUFPO0lBQ2hCLElBQUksRUFBRSxlQUFlLENBQUMsSUFBSTtJQUMxQixNQUFNLEVBQUUsZUFBZTtJQUN2QixnQkFBZ0IsRUFBRSxlQUFlLENBQUMsZ0JBQWdCO0lBQ2xELGdCQUFnQixFQUFFLGVBQWUsQ0FBQyxnQkFBZ0I7SUFDbEQsZUFBZSxFQUFFLGVBQWUsQ0FBQyxlQUFlO0lBQ2hELGFBQWEsRUFBRSxlQUFlLENBQUMsYUFBYTtDQUMvQyxDQUFDO0FBRUYsaUJBQVMsU0FBUyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0ZmlsZS5wbHVnaW5zXCIpO1xuaW1wb3J0IFNtYXJ0ZmlsZUNoZWNrcyA9IHJlcXVpcmUoXCIuL3NtYXJ0ZmlsZS5jaGVja3NcIik7XG5pbXBvcnQgU21hcnRmaWxlU2ltcGxlID0gcmVxdWlyZShcIi4vc21hcnRmaWxlLnNpbXBsZVwiKTtcblxuXG52YXIgc21hcnRmaWxlOmFueSA9IHtcbiAgICBjb3B5OiBTbWFydGZpbGVTaW1wbGUuY29weSxcbiAgICBjaGVja3M6IFNtYXJ0ZmlsZUNoZWNrcyxcbiAgICByZWFkRmlsZVRvU3RyaW5nOiBTbWFydGZpbGVTaW1wbGUucmVhZEZpbGVUb1N0cmluZyxcbiAgICByZWFkRmlsZVRvT2JqZWN0OiBTbWFydGZpbGVTaW1wbGUucmVhZEZpbGVUb09iamVjdCxcbiAgICByZWFkRmlsZVRvVmlueWw6IFNtYXJ0ZmlsZVNpbXBsZS5yZWFkRmlsZVRvVmlueWwsXG4gICAgcmVxdWlyZVJlbG9hZDogU21hcnRmaWxlU2ltcGxlLnJlcXVpcmVSZWxvYWRcbn07XG5cbmV4cG9ydCA9IHNtYXJ0ZmlsZTtcbiJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
33
dist/smartfile.checks.js
vendored
Normal file
33
dist/smartfile.checks.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
exports.fileExistsSync = function (filePath) {
|
||||||
|
var fileExistsBool = false;
|
||||||
|
try {
|
||||||
|
plugins.fs.readFileSync(filePath);
|
||||||
|
fileExistsBool = true;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
fileExistsBool = false;
|
||||||
|
}
|
||||||
|
return fileExistsBool;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
exports.fileExists = function (filePath) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
||||||
|
err ? done.reject() : done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5jaGVja3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBRWhEOzs7O0dBSUc7QUFDUSxzQkFBYyxHQUFHLFVBQVMsUUFBUTtJQUN6QyxJQUFJLGNBQWMsR0FBVyxLQUFLLENBQUM7SUFDbkMsSUFBSSxDQUFDO1FBQ0QsT0FBTyxDQUFDLEVBQUUsQ0FBQyxZQUFZLENBQUMsUUFBUSxDQUFDLENBQUM7UUFDbEMsY0FBYyxHQUFHLElBQUksQ0FBQTtJQUN6QixDQUNBO0lBQUEsS0FBSyxDQUFBLENBQUMsR0FBRyxDQUFDLENBQUEsQ0FBQztRQUNQLGNBQWMsR0FBRyxLQUFLLENBQUM7SUFDM0IsQ0FBQztJQUNELE1BQU0sQ0FBQyxjQUFjLENBQUM7QUFDMUIsQ0FBQyxDQUFDO0FBRUY7Ozs7R0FJRztBQUNRLGtCQUFVLEdBQUcsVUFBUyxRQUFRO0lBQ3JDLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFL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rpb24oZmlsZVBhdGgpe1xuICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgcGx1Z2lucy5mcy5hY2Nlc3MoZmlsZVBhdGgsIHBsdWdpbnMuZnMuUl9PSywgZnVuY3Rpb24gKGVycikge1xuICAgICAgICBlcnIgPyBkb25lLnJlamVjdCgpIDogZG9uZS5yZXNvbHZlKCk7XG4gICAgfSk7XG4gICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbn07XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
13
dist/smartfile.plugins.js
vendored
Normal file
13
dist/smartfile.plugins.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
exports.beautylog = require("beautylog");
|
||||||
|
exports.fs = require("fs-extra");
|
||||||
|
exports.path = require("path");
|
||||||
|
exports.q = require("q");
|
||||||
|
exports.vinyl = require("vinyl");
|
||||||
|
exports.vinylFile = require("vinyl-file");
|
||||||
|
exports.yaml = require("js-yaml");
|
||||||
|
exports.requireReload = require("require-reload");
|
||||||
|
exports.shelljs = require("shelljs");
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDakMsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDakMsVUFBRSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztBQUN6QixZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLFNBQUMsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUM7QUFDakIsYUFBSyxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUN6QixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQztBQUNsQyxZQUFJLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLHFCQUFhLEdBQUcsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBQUM7QUFDMUMsZUFBTyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydGZpbGUucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgZnMgPSByZXF1aXJlKFwiZnMtZXh0cmFcIik7XG5leHBvcnQgbGV0IHBhdGggPSByZXF1aXJlKFwicGF0aFwiKTtcbmV4cG9ydCBsZXQgcSA9IHJlcXVpcmUoXCJxXCIpO1xuZXhwb3J0IGxldCB2aW55bCA9IHJlcXVpcmUoXCJ2aW55bFwiKTtcbmV4cG9ydCBsZXQgdmlueWxGaWxlID0gcmVxdWlyZShcInZpbnlsLWZpbGVcIik7XG5leHBvcnQgbGV0IHlhbWwgPSByZXF1aXJlKFwianMteWFtbFwiKTtcbmV4cG9ydCBsZXQgcmVxdWlyZVJlbG9hZCA9IHJlcXVpcmUoXCJyZXF1aXJlLXJlbG9hZFwiKTtcbmV4cG9ydCBsZXQgc2hlbGxqcyA9IHJlcXVpcmUoXCJzaGVsbGpzXCIpO1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
69
dist/smartfile.simple.js
vendored
Normal file
69
dist/smartfile.simple.js
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
"use strict";
|
||||||
|
var plugins = require("./smartfile.plugins");
|
||||||
|
exports.copy = function (fromArg, toArg) {
|
||||||
|
plugins.shelljs.cp("-r", fromArg, toArg);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* reads a file content to a String
|
||||||
|
* @param filePath
|
||||||
|
* @returns {string|Buffer|any}
|
||||||
|
*/
|
||||||
|
exports.readFileToString = function (filePath) {
|
||||||
|
var fileString;
|
||||||
|
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
||||||
|
return fileString;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @param fileTypeArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
exports.readFileToObject = function (filePath, fileTypeArg) {
|
||||||
|
if (fileTypeArg === void 0) { fileTypeArg = undefined; }
|
||||||
|
var fileType;
|
||||||
|
if (typeof fileTypeArg == "undefined") {
|
||||||
|
fileType = plugins.path.extname(filePath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fileType = fileTypeArg;
|
||||||
|
}
|
||||||
|
fileType = fileType.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
|
||||||
|
switch (fileType) {
|
||||||
|
case "yml":
|
||||||
|
case "yaml":
|
||||||
|
try {
|
||||||
|
return plugins.yaml.safeLoad(plugins.fs.readFileSync(filePath, 'utf8'));
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
plugins.beautylog.error("check that " + filePath.blue + " points to a valid file");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "json":
|
||||||
|
return plugins.fs.readJsonSync(filePath, {});
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("file type " + fileType.blue + " not supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePathArg
|
||||||
|
* @param options
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
exports.readFileToVinyl = function (filePathArg, options) {
|
||||||
|
if (options === void 0) { options = {}; }
|
||||||
|
return plugins.vinylFile.readSync(filePathArg, options);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* lets you reload files hot.
|
||||||
|
* @param path
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
exports.requireReload = function (path) {
|
||||||
|
return plugins.requireReload(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5zaW1wbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDOztBQUU1QyxJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBRXJDLFlBQUksR0FBRyxVQUFTLE9BQWMsRUFBQyxLQUFZO0lBQ2xELE9BQU8sQ0FBQyxPQUFPLENBQUMsRUFBRSxDQUFDLElBQUksRUFBQyxPQUFPLEVBQUMsS0FBSyxDQUFDLENBQUM7QUFDM0MsQ0FBQyxDQUFDO0FBRUY7Ozs7R0FJRztBQUNRLHdCQUFnQixHQUFHLFVBQVMsUUFBUTtJQUMzQyxJQUFJLFVBQVUsQ0FBQztJQUNmLFVBQVUsR0FBRyxPQUFPLENBQUMsRUFBRSxDQUFDLFlBQVksQ0FBQyxRQUFRLEVBQUUsTUFBTSxDQUFDLENBQUM7SUFDdkQsTUFBTSxDQUFDLFVBQVUsQ0FBQztBQUN0QixDQUFDLENBQUM7QUFFRjs7Ozs7R0FLRztBQUNRLHdCQUFnQixHQUFHLFVBQVMsUUFBUSxFQUFDLFdBQXVCO0lBQXZCLDJCQUF1QixHQUF2Qix1QkFBdUI7SUFDbkUsSUFBSSxRQUFRLENBQUM7SUFDYixFQUFFLENBQUMsQ0FBQyxPQUFPLFdBQVcsSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ3BDLFFBQVEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUM5QyxDQUFDO0l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XBlLmJsdWUgKyBcIiBub3Qgc3VwcG9ydGVkXCIpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgfVxufTtcblxuLyoqXG4gKlxuICogQHBhcmFtIGZpbGVQYXRoQXJnXG4gKiBAcGFyYW0gb3B0aW9uc1xuICogQHJldHVybnMge251bWJlcn1cbiAqL1xuZXhwb3J0IGxldCByZWFkRmlsZVRvVmlueWwgPSBmdW5jdGlvbihmaWxlUGF0aEFyZyxvcHRpb25zID0ge30pIHtcbiAgICByZXR1cm4gcGx1Z2lucy52aW55bEZpbGUucmVhZFN5bmMoZmlsZVBhdGhBcmcsb3B0aW9ucyk7XG59O1xuXG4vKipcbiAqIGxldHMgeW91IHJlbG9hZCBmaWxlcyBob3QuXG4gKiBAcGFyYW0gcGF0aFxuICogQHJldHVybnMge2FueX1cbiAqL1xuZXhwb3J0IGxldCByZXF1aXJlUmVsb2FkID0gZnVuY3Rpb24ocGF0aDpzdHJpbmcpe1xuICAgIHJldHVybiBwbHVnaW5zLnJlcXVpcmVSZWxvYWQocGF0aCk7XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
36
index.d.ts
vendored
36
index.d.ts
vendored
@ -1,36 +0,0 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
|
||||||
declare module SmartfilePlugins {
|
|
||||||
var init: () => {
|
|
||||||
beautylog: any;
|
|
||||||
fs: any;
|
|
||||||
path: any;
|
|
||||||
q: any;
|
|
||||||
vinyl: any;
|
|
||||||
vinylFile: any;
|
|
||||||
yaml: any;
|
|
||||||
requireReload: any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
declare module SmartfileCheck {
|
|
||||||
var init: (objectArg: any) => void;
|
|
||||||
}
|
|
||||||
declare module SmartfileSimple {
|
|
||||||
var init: (objectArg: any) => void;
|
|
||||||
}
|
|
||||||
declare module SmartfileVinyl {
|
|
||||||
var init: (objectArg: any) => void;
|
|
||||||
}
|
|
||||||
declare module SmartfileRequire {
|
|
||||||
var init: (objectArg: any) => void;
|
|
||||||
}
|
|
||||||
declare var plugins: {
|
|
||||||
beautylog: any;
|
|
||||||
fs: any;
|
|
||||||
path: any;
|
|
||||||
q: any;
|
|
||||||
vinyl: any;
|
|
||||||
vinylFile: any;
|
|
||||||
yaml: any;
|
|
||||||
requireReload: any;
|
|
||||||
};
|
|
||||||
declare var smartfile: any;
|
|
123
index.js
123
index.js
@ -1,123 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfilePlugins;
|
|
||||||
(function (SmartfilePlugins) {
|
|
||||||
SmartfilePlugins.init = function () {
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
fs: require("fs-extra"),
|
|
||||||
path: require("path"),
|
|
||||||
q: require("q"),
|
|
||||||
vinyl: require("vinyl"),
|
|
||||||
vinylFile: require("vinyl-file"),
|
|
||||||
yaml: require("js-yaml"),
|
|
||||||
requireReload: require("require-reload")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
};
|
|
||||||
})(SmartfilePlugins || (SmartfilePlugins = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileCheck;
|
|
||||||
(function (SmartfileCheck) {
|
|
||||||
var checks = {
|
|
||||||
fileExistsSync: function (filePath) {
|
|
||||||
var fileExistsBool = false;
|
|
||||||
try {
|
|
||||||
plugins.fs.readFileSync(filePath);
|
|
||||||
fileExistsBool = true;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
fileExistsBool = false;
|
|
||||||
}
|
|
||||||
return fileExistsBool;
|
|
||||||
},
|
|
||||||
fileExists: function (filePath) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
|
||||||
err ? done.reject() : done.resolve();
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
SmartfileCheck.init = function (objectArg) {
|
|
||||||
objectArg.checks = checks;
|
|
||||||
};
|
|
||||||
})(SmartfileCheck || (SmartfileCheck = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileSimple;
|
|
||||||
(function (SmartfileSimple) {
|
|
||||||
/**
|
|
||||||
* reads a file content to a String
|
|
||||||
* @param filePath
|
|
||||||
* @returns {string|Buffer|any}
|
|
||||||
*/
|
|
||||||
var readFileToString = function (filePath) {
|
|
||||||
var fileString;
|
|
||||||
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
|
||||||
return fileString;
|
|
||||||
};
|
|
||||||
var readFileToObject = function (filePath, fileTypeArg) {
|
|
||||||
if (fileTypeArg === void 0) { fileTypeArg = "undefined"; }
|
|
||||||
var fileType;
|
|
||||||
if (fileTypeArg == "undefined") {
|
|
||||||
fileType = plugins.path.extname(filePath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fileType = fileTypeArg;
|
|
||||||
}
|
|
||||||
fileType = fileType.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
|
|
||||||
switch (fileType) {
|
|
||||||
case "yml":
|
|
||||||
case "yaml":
|
|
||||||
try {
|
|
||||||
return plugins.yaml.safeLoad(plugins.fs.readFileSync(filePath, 'utf8'));
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
plugins.beautylog.error("check that " + filePath.blue + " points to a valid file");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "json":
|
|
||||||
return plugins.fs.readJsonSync(filePath, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
SmartfileSimple.init = function (objectArg) {
|
|
||||||
objectArg.readFileToString = readFileToString;
|
|
||||||
objectArg.readFileToObject = readFileToObject;
|
|
||||||
};
|
|
||||||
})(SmartfileSimple || (SmartfileSimple = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileVinyl;
|
|
||||||
(function (SmartfileVinyl) {
|
|
||||||
var readFileToVinyl = function (filePathArg, options) {
|
|
||||||
if (options === void 0) { options = {}; }
|
|
||||||
return plugins.vinylFile.readSync(filePathArg, options);
|
|
||||||
};
|
|
||||||
SmartfileVinyl.init = function (objectArg) {
|
|
||||||
objectArg.readFileToVinyl = readFileToVinyl;
|
|
||||||
};
|
|
||||||
})(SmartfileVinyl || (SmartfileVinyl = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartfileRequire;
|
|
||||||
(function (SmartfileRequire) {
|
|
||||||
var requireReload = function (path) {
|
|
||||||
return plugins.requireReload(path);
|
|
||||||
};
|
|
||||||
SmartfileRequire.init = function (objectArg) {
|
|
||||||
objectArg.requireReload = requireReload;
|
|
||||||
};
|
|
||||||
})(SmartfileRequire || (SmartfileRequire = {}));
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
/// <reference path="./smartfile.plugins.ts" />
|
|
||||||
/// <reference path="./smartfile.check.ts" />
|
|
||||||
/// <reference path="./smartfile.simple.ts" />
|
|
||||||
/// <reference path="./smartfile.vinyl.ts" />
|
|
||||||
/// <reference path="./smartfile.require.ts" />
|
|
||||||
var plugins = SmartfilePlugins.init();
|
|
||||||
var smartfile = {};
|
|
||||||
SmartfileCheck.init(smartfile);
|
|
||||||
SmartfileSimple.init(smartfile);
|
|
||||||
SmartfileVinyl.init(smartfile);
|
|
||||||
SmartfileRequire.init(smartfile);
|
|
||||||
module.exports = smartfile;
|
|
14
package.json
14
package.json
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "smartfile",
|
"name": "smartfile",
|
||||||
"version": "0.0.12",
|
"version": "1.0.0",
|
||||||
"description": "offers smart ways to work with files in nodejs",
|
"description": "offers smart ways to work with files in nodejs",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(npmts)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"reinstall": "(rm -r node_modules && npm install)",
|
||||||
@ -25,17 +25,17 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartfile",
|
"homepage": "https://github.com/pushrocks/smartfile",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "2.0.6",
|
"beautylog": "3.1.2",
|
||||||
"fs-extra": "0.26.5",
|
"fs-extra": "0.26.5",
|
||||||
"js-yaml": "3.5.2",
|
"js-yaml": "3.5.4",
|
||||||
"q": "^1.4.1",
|
"q": "1.4.1",
|
||||||
"require-reload": "0.2.2",
|
"require-reload": "0.2.2",
|
||||||
|
"shelljs": "^0.6.0",
|
||||||
"vinyl": "1.1.1",
|
"vinyl": "1.1.1",
|
||||||
"vinyl-file": "2.0.0"
|
"vinyl-file": "2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"beautylog": "2.0.7",
|
"npmts": "3.4.1",
|
||||||
"npmts": "2.2.2",
|
|
||||||
"should": "^8.2.2"
|
"should": "^8.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
test/test.d.ts
vendored
5
test/test.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
|
||||||
declare var smartfile: any;
|
|
||||||
declare var beautylog: any;
|
|
||||||
declare var should: any;
|
|
||||||
declare var vinyl: any;
|
|
21
test/test.js
21
test/test.js
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
var smartfile = require("../dist/index.js");
|
||||||
/// <reference path="typings/main.d.ts" />
|
|
||||||
var smartfile = require("../index.js");
|
|
||||||
var beautylog = require("beautylog");
|
var beautylog = require("beautylog");
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var vinyl = require("vinyl");
|
var vinyl = require("vinyl");
|
||||||
@ -17,6 +15,9 @@ describe("smartfile", function () {
|
|||||||
testData.should.have.property("key1", "this works");
|
testData.should.have.property("key1", "this works");
|
||||||
testData.should.have.property("key2", "this works too");
|
testData.should.have.property("key2", "this works too");
|
||||||
});
|
});
|
||||||
|
it("should state unknown file type for unknown file types", function () {
|
||||||
|
var testData = smartfile.readFileToObject("./test/mytest.txt");
|
||||||
|
});
|
||||||
it("should read an " + ".json".blue + " file to an object", function () {
|
it("should read an " + ".json".blue + " file to an object", function () {
|
||||||
var testData = smartfile.readFileToObject("./test/mytest.json");
|
var testData = smartfile.readFileToObject("./test/mytest.json");
|
||||||
testData.should.have.property("key1", "this works");
|
testData.should.have.property("key1", "this works");
|
||||||
@ -44,4 +45,16 @@ describe("smartfile", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe("copy", function () {
|
||||||
|
it("should copy a directory", function () {
|
||||||
|
smartfile.copy("./test/testfolder/", "./test/assets/");
|
||||||
|
});
|
||||||
|
it("should copy a file", function () {
|
||||||
|
smartfile.copy("./test/mytest.yaml", "./test/assets/");
|
||||||
|
});
|
||||||
|
it("should copy a file and rename it", function () {
|
||||||
|
smartfile.copy("./test/mytest.yaml", "./test/assets/mytestRenamed.yaml");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=test.js.map
|
1
test/test.js.map
Normal file
1
test/test.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC5C,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,QAAQ,CAAC,WAAW,EAAC;IACjB,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EAAC;QAChC,EAAE,CAAC,gCAAgC,EAAC;YAChC,MAAM,CAAC,KAAK,CAC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YACpB,SAAS,CAAC,IAAI,CAAC,oBAAoB,EAAC,gBAAgB,CAAC,CAAA;QACzD,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,kCAAkC,EAAC;YAClC,SAAS,CAAC,IAAI,CAAC,oBAAoB,EAAC,kCAAkC,CAAC,CAAA;QAC3E,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@ -1,8 +1,9 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
var smartfile = require("../index.js");
|
var smartfile = require("../dist/index.js");
|
||||||
var beautylog = require("beautylog");
|
var beautylog = require("beautylog");
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var vinyl = require("vinyl");
|
var vinyl = require("vinyl");
|
||||||
|
|
||||||
describe("smartfile",function(){
|
describe("smartfile",function(){
|
||||||
describe(".readFileToString".yellow,function(){
|
describe(".readFileToString".yellow,function(){
|
||||||
it("should read a file to a string",function(){
|
it("should read a file to a string",function(){
|
||||||
@ -19,6 +20,9 @@ describe("smartfile",function(){
|
|||||||
testData.should.have.property("key2","this works too");
|
testData.should.have.property("key2","this works too");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
it("should state unknown file type for unknown file types",function(){
|
||||||
|
var testData = smartfile.readFileToObject("./test/mytest.txt");
|
||||||
|
});
|
||||||
it("should read an " + ".json".blue + " file to an object",function(){
|
it("should read an " + ".json".blue + " file to an object",function(){
|
||||||
var testData = smartfile.readFileToObject("./test/mytest.json");
|
var testData = smartfile.readFileToObject("./test/mytest.json");
|
||||||
testData.should.have.property("key1","this works");
|
testData.should.have.property("key1","this works");
|
||||||
@ -48,4 +52,15 @@ describe("smartfile",function(){
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
describe("copy",function(){
|
||||||
|
it("should copy a directory",function(){
|
||||||
|
smartfile.copy("./test/testfolder/","./test/assets/")
|
||||||
|
});
|
||||||
|
it("should copy a file",function(){
|
||||||
|
smartfile.copy("./test/mytest.yaml","./test/assets/")
|
||||||
|
});
|
||||||
|
it("should copy a file and rename it",function(){
|
||||||
|
smartfile.copy("./test/mytest.yaml","./test/assets/mytestRenamed.yaml")
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
0
test/testfolder/testfile1.txt
Normal file
0
test/testfolder/testfile1.txt
Normal file
0
test/testfolder/testfile2.txt
Normal file
0
test/testfolder/testfile2.txt
Normal file
28
ts/index.ts
28
ts/index.ts
@ -1,19 +1,17 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
/// <reference path="./smartfile.plugins.ts" />
|
|
||||||
/// <reference path="./smartfile.check.ts" />
|
import plugins = require("./smartfile.plugins");
|
||||||
/// <reference path="./smartfile.simple.ts" />
|
import SmartfileChecks = require("./smartfile.checks");
|
||||||
/// <reference path="./smartfile.vinyl.ts" />
|
import SmartfileSimple = require("./smartfile.simple");
|
||||||
/// <reference path="./smartfile.require.ts" />
|
|
||||||
var plugins = SmartfilePlugins.init();
|
|
||||||
|
|
||||||
|
|
||||||
var smartfile:any = {};
|
var smartfile:any = {
|
||||||
SmartfileCheck.init(smartfile);
|
copy: SmartfileSimple.copy,
|
||||||
SmartfileSimple.init(smartfile);
|
checks: SmartfileChecks,
|
||||||
SmartfileVinyl.init(smartfile);
|
readFileToString: SmartfileSimple.readFileToString,
|
||||||
SmartfileRequire.init(smartfile);
|
readFileToObject: SmartfileSimple.readFileToObject,
|
||||||
|
readFileToVinyl: SmartfileSimple.readFileToVinyl,
|
||||||
|
requireReload: SmartfileSimple.requireReload
|
||||||
|
};
|
||||||
|
|
||||||
|
export = smartfile;
|
||||||
|
|
||||||
|
|
||||||
module.exports = smartfile;
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
module SmartfileCheck {
|
|
||||||
var checks = {
|
|
||||||
fileExistsSync: function(filePath):boolean {
|
|
||||||
var fileExistsBool:boolean = false;
|
|
||||||
try {
|
|
||||||
plugins.fs.readFileSync(filePath)
|
|
||||||
fileExistsBool = true
|
|
||||||
}
|
|
||||||
catch(err){
|
|
||||||
fileExistsBool = false;
|
|
||||||
}
|
|
||||||
return fileExistsBool;
|
|
||||||
},
|
|
||||||
fileExists: function(filePath){
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
|
||||||
err ? done.reject() : done.resolve();
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
export var init = function(objectArg){
|
|
||||||
objectArg.checks = checks;
|
|
||||||
}
|
|
||||||
}
|
|
32
ts/smartfile.checks.ts
Normal file
32
ts/smartfile.checks.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./smartfile.plugins");
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export let fileExistsSync = function(filePath):boolean {
|
||||||
|
let fileExistsBool:boolean = false;
|
||||||
|
try {
|
||||||
|
plugins.fs.readFileSync(filePath);
|
||||||
|
fileExistsBool = true
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
fileExistsBool = false;
|
||||||
|
}
|
||||||
|
return fileExistsBool;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let fileExists = function(filePath){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
||||||
|
err ? done.reject() : done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1,16 +1,10 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module SmartfilePlugins {
|
export let beautylog = require("beautylog");
|
||||||
export var init = function() {
|
export let fs = require("fs-extra");
|
||||||
var plugins = {
|
export let path = require("path");
|
||||||
beautylog: require("beautylog"),
|
export let q = require("q");
|
||||||
fs: require("fs-extra"),
|
export let vinyl = require("vinyl");
|
||||||
path: require("path"),
|
export let vinylFile = require("vinyl-file");
|
||||||
q: require("q"),
|
export let yaml = require("js-yaml");
|
||||||
vinyl: require("vinyl"),
|
export let requireReload = require("require-reload");
|
||||||
vinylFile: require("vinyl-file"),
|
export let shelljs = require("shelljs");
|
||||||
yaml: require("js-yaml"),
|
|
||||||
requireReload: require("require-reload")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
module SmartfileRequire {
|
|
||||||
var requireReload = function(path:string){
|
|
||||||
return plugins.requireReload(path);
|
|
||||||
};
|
|
||||||
|
|
||||||
export var init = function(objectArg){
|
|
||||||
objectArg.requireReload = requireReload;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +1,31 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module SmartfileSimple {
|
|
||||||
/**
|
import plugins = require("./smartfile.plugins");
|
||||||
|
|
||||||
|
export let copy = function(fromArg:string,toArg:string){
|
||||||
|
plugins.shelljs.cp("-r",fromArg,toArg);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
* reads a file content to a String
|
* reads a file content to a String
|
||||||
* @param filePath
|
* @param filePath
|
||||||
* @returns {string|Buffer|any}
|
* @returns {string|Buffer|any}
|
||||||
*/
|
*/
|
||||||
var readFileToString = function(filePath) {
|
export let readFileToString = function(filePath) {
|
||||||
var fileString;
|
let fileString;
|
||||||
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
||||||
return fileString;
|
return fileString;
|
||||||
};
|
};
|
||||||
var readFileToObject = function(filePath,fileTypeArg = "undefined") {
|
|
||||||
var fileType;
|
/**
|
||||||
if (fileTypeArg == "undefined") {
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @param fileTypeArg
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let readFileToObject = function(filePath,fileTypeArg = undefined) {
|
||||||
|
let fileType;
|
||||||
|
if (typeof fileTypeArg == "undefined") {
|
||||||
fileType = plugins.path.extname(filePath);
|
fileType = plugins.path.extname(filePath);
|
||||||
} else {
|
} else {
|
||||||
fileType = fileTypeArg;
|
fileType = fileTypeArg;
|
||||||
@ -29,11 +42,27 @@ module SmartfileSimple {
|
|||||||
break;
|
break;
|
||||||
case "json":
|
case "json":
|
||||||
return plugins.fs.readJsonSync(filePath,{});
|
return plugins.fs.readJsonSync(filePath,{});
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("file type " + fileType.blue + " not supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export var init = function(objectArg) {
|
|
||||||
objectArg.readFileToString = readFileToString;
|
/**
|
||||||
objectArg.readFileToObject = readFileToObject;
|
*
|
||||||
};
|
* @param filePathArg
|
||||||
}
|
* @param options
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
export let readFileToVinyl = function(filePathArg,options = {}) {
|
||||||
|
return plugins.vinylFile.readSync(filePathArg,options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lets you reload files hot.
|
||||||
|
* @param path
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
export let requireReload = function(path:string){
|
||||||
|
return plugins.requireReload(path);
|
||||||
|
};
|
@ -1,9 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
module SmartfileVinyl {
|
|
||||||
var readFileToVinyl = function(filePathArg,options = {}) {
|
|
||||||
return plugins.vinylFile.readSync(filePathArg,options);
|
|
||||||
};
|
|
||||||
export var init = function(objectArg) {
|
|
||||||
objectArg.readFileToVinyl = readFileToVinyl;
|
|
||||||
};
|
|
||||||
}
|
|
@ -3,6 +3,6 @@
|
|||||||
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts",
|
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts",
|
||||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
|
||||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts"
|
"node": "registry:dt/node#4.0.0+20160311162451"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user